c# - Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding -


when run code following exception:

an unhandled exception of type 'system.data.sqlclient.sqlexception' occurred in system.data.dll

additional information: execution timeout expired. timeout period elapsed prior completion of operation or server not responding.

my code following:

    private void fillindatagrid(string sqlstring)     {         string cn = configurationmanager.connectionstrings["scratchpad"].connectionstring; //hier wordt de databasestring opgehaald         sqlconnection myconnection = new sqlconnection(cn);         sqldataadapter dataadapter = new sqldataadapter(sqlstring, myconnection);         dataset ds = new dataset();         myconnection.open();         dataadapter.fill(ds, "authors_table");         myconnection.close();         datagridview1.datasource = ds;         datagridview1.datamember = "authors_table";     } 

and sqlstring following:

select dbo.[new].[colom1],dbo.[new].[colom2],dbo.[new].[colom3],dbo.[new].[colom4],                   dbo.[new].[value] 'nieuwe value',                 dbo.[old].[value] 'oude value'                 dbo.[new]                 join dbo.[old] on dbo.[new].[colom1] = dbo.[old].[colom1] , dbo.[new].[colom2] = dbo.[old].[colom2] , dbo.[new].[colom3] = dbo.[old].[colom3] , dbo.[new].[colom4] = dbo.[old].[colom4]                  dbo.[new].[value] <> dbo.[old].[value] 

if query needs more default 30 seconds, might want set commandtimeout higher. you'll change after instantiated dataadapter on selectcommand property of instance, so:

private void fillindatagrid(string sqlstring) {     string cn = configurationmanager.connectionstrings["scratchpad"].connectionstring; //hier wordt de databasestring opgehaald     dataset ds = new dataset();     // dispose objects implement idisposable     using(sqlconnection myconnection = new sqlconnection(cn))     {         sqldataadapter dataadapter = new sqldataadapter(sqlstring, myconnection);          // set commandtimeout         dataadapter.selectcommand.commandtimeout = 60;  // seconds          myconnection.open();         dataadapter.fill(ds, "authors_table");      }     datagridview1.datasource = ds;     datagridview1.datamember = "authors_table"; } 

the other option address query. in sql server can analyze execution plan. bet there full-table scan in it. might experiment adding index on 1 or 2 columns in [old] , [new] table. keep in mind adding indexes comes @ cost of higher execution times inserts , updates , space requirements.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -