2012-04-30 9 views
0

クライアントのプロダクションサーバー(わずかな権限がある)で発生するSQL例外があります。SQL例外のトレース

問題をローカルに複製することはできませんが、どのようなsql例外が呼び出されているのか、どのsqlを使用しているのか把握する方法はありますか?再デプロイして、ソースコードの変更にアクセスできます。

私のスタックトレースは、このようなものです:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

Stack Trace: 
[SqlException (0x80131904): ] 

System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +1950954 
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4846939 
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194 
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2392 
System.Data.SqlClient.SqlDataReader.CloseInternal(Boolean closeReader) +169 
System.Data.SqlClient.SqlDataReader.Close() +96 
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +292 
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +954 
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +162 
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +32 
System.Data.SqlClient.SqlCommand.ExecuteScalar() +139 
Output.RunTable(String outputType, String _outputDataType) +1106 
Output.ProcessPage() +33 
Output.Page_Load(Object sender, EventArgs e) +6466 
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14 
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35 
System.Web.UI.Control.OnLoad(EventArgs e) +99 
System.Web.UI.Control.LoadRecursive() +50 
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627 
+0

私は例外のメッセージを信じて、それはです内部の例外メッセージは、これよりも多くの手伝いをすることができます。 – gdoron

+0

例外メッセージをどこから取得するのかはどうすればわかりますか? – cdub

+0

SQL Serverから返されるエラーメッセージは、SqlException(3レベルの深さ)の内部例外の*内部例外*にあります。そのため、SQLを取得するために 'exception.GetBaseException()。Message 'サーバーエラー。 –

答えて

4

は(MSDN articleから取られた)例外に関するより多くの情報を収集するために、次のアプローチを使用してみてください:

try 
    { 
     command.Connection.Open(); 
     command.ExecuteNonQuery(); 
    } 
    catch (SqlException ex) 
    { 
     for (int i = 0; i < ex.Errors.Count; i++) 
     { 
      errorMessages.Append("Index #" + i + "\n" + 
       "Message: " + ex.Errors[i].Message + "\n" + 
       "LineNumber: " + ex.Errors[i].LineNumber + "\n" + 
       "Source: " + ex.Errors[i].Source + "\n" + 
       "Procedure: " + ex.Errors[i].Procedure + "\n"); 
     } 
     Console.WriteLine(errorMessages.ToString()); 
    } 
+0

ありがとう私はこのような助けを探していた:) – cdub

関連する問題