prochko
asked on
Adding a TimeOut parameter to a <asp:SQLDataSource
Would like to know if there is a way to add a timeout parameter to the <asp:SqlDataSource command.
<asp:SqlDataSource ConnectionString="<%$ ConnectionStrings:MTASP2Co nnectionSt ring %>"
ID="SqlDataViewJobs"
EnableCaching="true"
runat="server"
SelectCommand=""
DataSourceMode = "DataSet"
OnSelected="SqlDataViewJob s_Selected ">
<SelectParameters>
</SelectParameters>
</asp:SqlDataSource>
I tried an alternative approach (below), but for some reason Sorting and Paging no longer work:
SqlConnection SqlConn = Data.GetSqlConn();
SqlConn.Open();
SqlCommand SqlCmd = new SqlCommand(SQL, SqlConn);
SqlCmd.CommandTimeout = 120;
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = SqlCmd;
DataSet myDataSet = new DataSet();
adapter.Fill(myDataSet);
GridViewJobs.DataSource = myDataSet.Tables[0];
GridViewJobs.DataBind();
SqlConn.Close();
int count = myDataSet.Tables[0].Rows.C ount;
Any advice is appreciated. Thanks
<asp:SqlDataSource ConnectionString="<%$ ConnectionStrings:MTASP2Co
ID="SqlDataViewJobs"
EnableCaching="true"
runat="server"
SelectCommand=""
DataSourceMode = "DataSet"
OnSelected="SqlDataViewJob
<SelectParameters>
</SelectParameters>
</asp:SqlDataSource>
I tried an alternative approach (below), but for some reason Sorting and Paging no longer work:
SqlConnection SqlConn = Data.GetSqlConn();
SqlConn.Open();
SqlCommand SqlCmd = new SqlCommand(SQL, SqlConn);
SqlCmd.CommandTimeout = 120;
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = SqlCmd;
DataSet myDataSet = new DataSet();
adapter.Fill(myDataSet);
GridViewJobs.DataSource = myDataSet.Tables[0];
GridViewJobs.DataBind();
SqlConn.Close();
int count = myDataSet.Tables[0].Rows.C
Any advice is appreciated. Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You are correct. I had to add a bunch of code in order to keep track of the Page Number and Sort Fields (both ASC and DESC). Here is some of the code:
if (ViewState["JobsDataSet"] == null)
{
SqlConnection SqlConn = Data.GetSqlConn();
SqlConn.Open();
SqlCommand SqlCmd = new SqlCommand(SQL, SqlConn);
SqlCmd.CommandTimeout = 120;
adapter.SelectCommand = SqlCmd;
adapter.Fill(myDataSet, "Jobs");
ViewState["JobsDataSet"] = myDataSet;
SqlConn.Close();
}
else
{
myDataSet = (DataSet)ViewState["JobsDa taSet"];
}
// Prepare the sort expression using the gridSortDirection and gridSortExpression properties
string sortExpression;
if (gridSortDirection == SortDirection.Ascending)
sortExpression = gridSortExpression + " ASC";
else
sortExpression = gridSortExpression + " DESC";
// Sort the data
myDataSet.Tables["Jobs"].D efaultView .Sort = sortExpression;
// Bind to the GridView
GridViewJobs.DataSource = myDataSet.Tables["Jobs"].D efaultView ;
GridViewJobs.DataBind();
It would be a lot, lot easier if there was a way to change the TimeOut parameter on the asp:SqlDataSource control.
Thanks
if (ViewState["JobsDataSet"] == null)
{
SqlConnection SqlConn = Data.GetSqlConn();
SqlConn.Open();
SqlCommand SqlCmd = new SqlCommand(SQL, SqlConn);
SqlCmd.CommandTimeout = 120;
adapter.SelectCommand = SqlCmd;
adapter.Fill(myDataSet, "Jobs");
ViewState["JobsDataSet"] = myDataSet;
SqlConn.Close();
}
else
{
myDataSet = (DataSet)ViewState["JobsDa
}
// Prepare the sort expression using the gridSortDirection and gridSortExpression properties
string sortExpression;
if (gridSortDirection == SortDirection.Ascending)
sortExpression = gridSortExpression + " ASC";
else
sortExpression = gridSortExpression + " DESC";
// Sort the data
myDataSet.Tables["Jobs"].D
// Bind to the GridView
GridViewJobs.DataSource = myDataSet.Tables["Jobs"].D
GridViewJobs.DataBind();
It would be a lot, lot easier if there was a way to change the TimeOut parameter on the asp:SqlDataSource control.
Thanks
ASKER
if (ViewState["JobsDataSet"] == null)
{
SqlConnection SqlConn = Data.GetSqlConn();
SqlConn.Open();
SqlCommand SqlCmd = new SqlCommand(SQL, SqlConn);
SqlCmd.CommandTimeout = 120;
adapter.SelectCommand = SqlCmd;
adapter.Fill(myDataSet, "Jobs");
ViewState["JobsDataSet"] = myDataSet;
SqlConn.Close();
}
else
{
myDataSet = (DataSet)ViewState["JobsDa
}
// Prepare the sort expression using the gridSortDirection and gridSortExpression properties
string sortExpression;
if (gridSortDirection == SortDirection.Ascending)
sortExpression = gridSortExpression + " ASC";
else
sortExpression = gridSortExpression + " DESC";
// Sort the data
myDataSet.Tables["Jobs"].D
// Bind to the GridView
GridViewJobs.DataSource = myDataSet.Tables["Jobs"].D
GridViewJobs.DataBind();
It would be a lot, lot easier if there was a way to change the TimeOut parameter on the asp:SqlDataSource control.
Thanks