c# - Increasing the Command Timeout for SQL command -


i have little problem , hoping can give me advice. running sql command, appears takes command 2 mins return data there lot of data. default connection time 30 secs, how increase this, , apply command?

public static datatable runtotals(string assetnumberv, string assetnumber1v) {     datatable dtgetruntotals;      try     {         dtgetruntotals = new datatable("getruntotals");          //sqlparameter assetnumber = new sqlparameter("@assetnumber", sqldbtype.varchar, 6);         //assetnumber.value = assetnumberv;           sqlparameter assetnumber = new sqlparameter("@assetnumber", sqldbtype.varchar, 10);         assetnumber.value = assetnumberv;          sqlparameter assetnumber1 = new sqlparameter("@assetnumber1", sqldbtype.varchar, 10);         assetnumber1.value = assetnumber1v;          sqlcommand scgetruntotals = new sqlcommand("exec spruntotals @assetnumber,@assetnumber1 ", dataaccess.assetconnection);          // scgetruntotals.parameters.add(assetnumber);         scgetruntotals.parameters.add(assetnumber);         scgetruntotals.parameters.add(assetnumber1);          sqldataadapter sdagetruntotals = new sqldataadapter();         sdagetruntotals.selectcommand = scgetruntotals;         sdagetruntotals.fill(dtgetruntotals);          return dtgetruntotals;     }     catch (exception ex)     {         messagebox.show("error retriving totals details: processed error:" + ex.message);         return null;     } } 

it takes command 2 mins return data there lot of data

bad design. consider using paging here.

default connection time 30 secs, how increase this

as facing timout on command, therefore need increase timout of sql command. can specify in command this

// setting command timeout 2 minutes scgetruntotals.commandtimeout = 120; 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -