Monday, 26 August 2013

Increasing the Connection Timeout

Increasing the Connection Timeout

I have a little problem and hoping someone can give me some advice, i am
running a sql command, but it appears it takes this command about 2 mins
to return the data as there is a lot of data, but due to the default
connection time is 30 secs, how do i increase this, and apply it to this
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
with this error:" + ex.Message);
return null;
}
}

No comments:

Post a Comment