views:

110

answers:

3

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(Expression 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.

+1  A: 

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.

Randy Minder
A: 

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.

Femaref
so what does the "DataContext.SubmitChanges(ConflictMode failureMode)" in the error means?
sharru
this means that the error origins from Saving in the Linq2Sql context. The actual error is the connection to the sql server timing out.
Femaref
so its not a select error , its a insert error? so why is this written System.Data.Common.DbCommand.ExecuteReader()
sharru
@sharru: Do you have an identity column, or column(s) set by the database? If so LINQ to SQL will perform and insert, and immediately select the data to get the values set by the DB.
Richard
@richard: Yes i have identity column. this makes sense now.
sharru
A: 

Hi,

"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

Karel
sql server is on the local server , and connection is working.
sharru