Timeout Exception Caught When Using SqlDataAdapter
-
27 februarie 2007 10:48
Hi,
I have been asked to look after a C# asp.Net reporting system using an SQL database. Unofrtunately I have very little programming knowledge, hence I am here to ask for your help.
Straight to the point.
I get this exception caught by a Try - Catch statement:
{"Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding." }
By stepping through the code it seems this error occurs during this section of code:
public DataTable Query(string SQLCommand)
{
// Returns a datatable from a given SQL query
SqlDataAdapter sqlDA;
DataSet dsQueryResults;
sqlDA = new SqlDataAdapter(SQLCommand, Conn);
dsQueryResults = new DataSet();
sqlDA.Fill(dsQueryResults, "Results");
sqlDA.Dispose();
return dsQueryResults.Tables["Results"];
}
The specific line I think it falls over on is this (this is when it jumps to the catch statement)
sqlDA.Fill(dsQueryResults, "Results");
After stepping through the exception try-catch the debugger exits with a message box with the following message:
An unhandled exception of type 'System.Runtime.Serialization.SerializationException' occurred in Unknown Module.
Additional information: The type PrescLib.ReportGenerationException in Assembly PrescLib, Version=1.0.2613.16829, Culture=neutral, PublicKeyToken=null is not marked as serializable.Can anybody offer me any help with regard to this error? I you need further information then let me know (you may need to write the reply for a dummy as thats as far as I go!)
Thanks in advance!
Toate mesajele
-
27 februarie 2007 11:15
I have quickly changed the database which this queries to the 'live' database and it seems to be working correctly again...
This is leading me to believe there is some sort of Timeout setting for the 'test' database which I am unaware of. Does anybody know where this would be? Is it coded into the C# connection string or is this more of an SQL problem?
-
28 februarie 2007 09:44
Hi,
The timeout can be set in SqlConnection.ConnectionTimeout Property.
Gets the time to wait while trying to establish a connection before terminating the attempt and generating an error.
And try setting SQLCommand.CommandTimeout="NumOfSeconds"
to a higher value than the default 30 seconds.
Hope it helps. Thank you -
7 iulie 2007 02:59
Dear all,
I have trying to add the ConnectionTimeOut. Actually i have made 120. But the result, it's always return Timeout.
How to resolve this problem ?
-
6 mai 2008 16:23
data_adapter.SelectCommand.CommandTimeout = xxx fixed the problem for me- Propus ca răspuns de themanuelrc 7 aprilie 2012 15:06
-
7 aprilie 2012 15:06this is correct!