none
Timeout Exception Caught When Using SqlDataAdapter

    Soru

  • 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!

    27 Şubat 2007 Salı 10:48

Yanıtlar

  • 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

    28 Şubat 2007 Çarşamba 09:44

Tüm Yanıtlar

  • 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?

    27 Şubat 2007 Salı 11:15
  • 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

    28 Şubat 2007 Çarşamba 09:44
  • 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 ?

    07 Temmuz 2007 Cumartesi 02:59
  •  

    data_adapter.SelectCommand.CommandTimeout = xxx  fixed the problem for me
    • Yanıt Olarak Öneren themanuelrc 07 Nisan 2012 Cumartesi 15:06
    06 Mayıs 2008 Salı 16:23
  • this is correct!
    07 Nisan 2012 Cumartesi 15:06