开发者

Error on IIS for ASP.Net Application

I am facing this error occasionally. When I restart the IIS this problem is resolved. The web server(IIS) has more than 10 sites hosted, so i can't restart it simultaneously.

System.Data.SqlClient.SqlException: Distributed transaction completed. Either enlist
    this session in a new transaction or the NULL transaction. at 
    System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean 
    breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(S开发者_运维技巧qlException 
    exception, Boolean breakConnection) at 
    System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at 
    System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, 
    SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject 
    stateObj) at System.Data.SqlClient.SqlDataReader.ConsumeMetaData() at 
    System.Data.SqlClient.SqlDataReader.get_MetaData() at 
    System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior 
    runBehavior, String resetOptionsString) at         
    System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, 
    RunBehavior runBehavior, Boolean returnStream, Boolean async) at 
    System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior 
    runBehavior, Boolean returnStream, String method, DbAsyncResult result) at 
    System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior 
    runBehavior, Boolean returnStream, String method) at 
    System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at 
    System.Data.SqlClient.SqlCommand.ExecuteReader() at MyLibrary.LoadDDList(DropDownList& 
    curDDL, String strTextField, String strValueField, String strTable, String svarconditional)

Please help me find a solution which preferably doesn't involve restarting IIS.


You have a function called LoadDDList in the MyLibrary class.

This function needs a Try Catch around the ExecuteReader() command.

Try
    mySqlCommand.ExecuteReader()
Catch sqlException As SqlClient.SqlException
    If sqlException.ErrorCode >= 10 Then
        Throw
    End If
End Try

In the catch, you want to check for an ErrorCode less than 10. If it's less than 10, then it's just a warning message and you can ignore it. If it's 10 or greater, you need to rethrow it, since it's an actual SQL error (parsing error, invalid table, etc.).

Looking at your stack, this is just a warning and should be ignored. You need to fix your code so you won't crash IIS when you hit this SQL Warning.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜