开发者

.Net LINQ to SQL Exception

I'm using C# , .NET and SQL Server with Linq2SQL.

What does this error mean?

Is it a insert or read/select related error?

The function Classes.BLL.Save(LPage l) first selects COUNT from database and then INSERT a new record to database.

2010-09-03 04:57:56,264 System.Data.SqlClient.SqlException (0x80131904): Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
   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.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.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.ExecuteReader()
   at System.Data.Linq.SqlClient.SqlProvider.Execute(Expres开发者_运维技巧sion query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult)
   at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries)
   at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)
   at System.Data.Linq.ChangeDirector.StandardChangeDirector.DynamicInsert(TrackedObject item)
   at System.Data.Linq.ChangeDirector.StandardChangeDirector.Insert(TrackedObject item)
   at System.Data.Linq.ChangeProcessor.SubmitChanges(ConflictMode failureMode)
   at System.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode)
   at Classes.BLL.Save(LPage l)

Update:

I know this is a timeout exception and its coming from the sql server. but the error says two things ,

1) error in Common.DbCommand.ExecuteReader() and

2) error in DataContext.SubmitChanges(ConflictMode failureMode) ,

So I'm trying to find out if the source of the error is the select command or the insert command.


This error is coming from SQL Server and not Linq. It simply means the operation with SQL Server didn't respond within your designated time-out period (probably 30 seconds). This could be due to waiting on a lock being released on more or more records, or some other resource contention.


It's a select error - Insert queries would be done via ExecuteNonQuery if I remember right. Although, this error would probably appear in another way or form for Insert as well. It isn't caused by Linq but by the Sql Server though.


"Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding."

So it's probaly a timeout. Can you ping the sql server host? Did you try to create an UDL file and test your connection with that? (Right click in a folder, create a new empty text file, rename it to test.udl, double click to open and fill in the necessary connection data, then click test)

kind regards,

Karel

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜