Query timeout after 30 seconds using .net data provider and VS 2005 SP1

Tools

Query timeout after 30 seconds using .net data provider and VS 2005 SP1

Hello,

Currently i am having issue's when it comes to getting results of a query from a Teradata DW server if the query takes longer then 30 seconds to run. I know that this is the default, and i did look it up in the forums but i still can't seem to figure out how to change the commandtimeout parameter.

I am using .NET Data Provider for Teradata 13.00.00.00 driver with Visual Studios 2005 SP1 and the query with be run in a ASP.net webpage. I am creating the queries in a Dataset(xsd file) and then binding them to a dataviewer using a Ojectdatasource.

How would i go about changing the CommandTimeout default value?

thanks,
Matt
1 REPLY
Enthusiast

Re: Query timeout after 30 seconds using .net data provider and VS 2005 SP1

The easiest way to do this in ASP.NET is to use a SqlDataSource. You have to set the CommandTimeout in a script. An example is below in c# with the non-pertinent sections removed.

Selecting event - The CommandTimeout is in seconds and setting it to 0 is equivilent to do not ever timeout.
Selected event - This, in combination with setting the DataSourceMode to DataSet, lets me set a text box telling the number of records returned.

R

<script runat="server">
protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
e.Command.CommandTimeout = 0;
}

protected void SqlDataSource1_Selected(object sender, SqlDataSourceStatusEventArgs e)
{
if (e.AffectedRows == 0)
txtNoItems.Text = "No records found.";
else
txtNoItems.Text = e.AffectedRows.ToString("n0") + " records found.";
}
</script>

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="Your Connection String"
ProviderName="Teradata.Client.Provider"
SelectCommand="A SELECT COMMAND THAT TAKES A LONG TIME"
DataSourceMode="DataSet"
onselecting="SqlDataSource1_Selecting"
onselected="SqlDataSource1_Selected" >