user3547774
user3547774

Reputation: 1689

SQL Error Transport level

I get the following error at random intervals when executing my SQL Queries

Message: System.Data.SqlClient.SqlException (0x80131904): A transport-level error has     occurred when receiving results from the server. (provider: TCP Provider, error: 0     - The specified network name is no longer available.)
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean     breakConnection)'
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception,     Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
   at System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj, UInt32 error)
   at System.Data.SqlClient.TdsParserStateObject.ReadSni(DbAsyncResult asyncResult, TdsParserStateObject stateObj)
  at System.Data.SqlClient.TdsParserStateObject.ReadNetworkPacket()
at System.Data.SqlClient.TdsParserStateObject.ReadBuffer()
at System.Data.SqlClient.TdsParserStateObject.ReadByte()
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
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.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()`

I thought this might be due to a dropping network connection, is this correct? How do I code around this?

Upvotes: 0

Views: 822

Answers (1)

Sergey Kalinichenko
Sergey Kalinichenko

Reputation: 726779

I thought this might be due to a dropping network connection, is this correct?

Yes, "transport-level error" is a "geek talk" word for "network". This could also happen when the network connection becomes stale, for example, because your server gets rebooted after you obtain a connection and hold on to it for too long.

How do I code around this?

Unfortunately, there is not much you can do about network connections. You can use try/catch, look for SQL exception, and retry with a retry count, but eventually you report this to your end users.

Upvotes: 1

Related Questions