Data Adaptor

How can I set a higher commandtimeout value for the following dataset
I have 300,000 records and it gives timeout error in the .fill statement.

string str_SQL = "SELECT * FROM  mytbl";

SqlDataAdapter adptr_DataAdapter = new SqlDataAdapter(str_SQL, cnn_DataConnection);

DataSet DS = new DataSet();

adptr_DataAdapter.Fill(DS, str_table_name);




Answer this question

Data Adaptor

  • taral

    I think you need to adjust the both of the following:

    - The "Connect Timeout" in the connection string (integer in seconds).
    - "CommandTimeOut" Property in SqlCommand (integer in seconds).






  • Craig Cormier

    You should consider changing design of your application. For example, consider fetching only rows you need now, not all rows.< xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />



  • Charles Darwin

    Hi,

    Im not quite sure about this. But I think you can do it this way:

    string str_SQL = "SELECT * FROM  mytbl";
    SqlDataAdapter adptr_DataAdapter = new SqlDataAdapter(str_SQL,cnn_DataConnection);
    DataSet DS = new DataSet();
    adptr_DataAdapter.SelectCommand.CommandTimeout = 300;
    adptr_DataAdapter.Fill(DS, str_table_name);



    cheers,

    Paul June A. Domag


  • Data Adaptor