Link to home
Start Free TrialLog in
Avatar of kevlause
kevlause

asked on

Timeout Expired when trying to bind gridview with sql datasource

I've got a grid view that is bound to a sql datasource that uses a connection string set in a web config file.

When I run a large sql query I get the time out error. I've set the timeout in the connection string (I think) but I'm still getting this error.

System.Data.SqlClient.SqlException: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.

Here is the connection string I'm using
connectionString="Data Source=XXX;Initial Catalog=XXX;Integrated Security=True;timeout=9999999"

What else do I need to do here? Is there a time out I can set on the server it's self?
Avatar of nito8300
nito8300
Flag of United States of America image

try this:
      objConnection.ConnectionTimeout = 0
      objConnection.CommandTimeout = 0
Avatar of kevlause
kevlause

ASKER

Where?
What is objconnection? I've set the datasource for my datagrid to sqldatasource2.
ASKER CERTIFIED SOLUTION
Avatar of nito8300
nito8300
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I set the connectionstring in the webconfig file  
<connectionStrings>
<add name="xxxConnectionString" connectionString="Data Source=xxx;Initial Catalog=xxx;Integrated Security=True;timeout=9999999"  providerName="System.Data.SqlClient"/>
</connectionStrings>


Then in my ASPX page I have this code:

<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:XXXConnectionString %>">
           </asp:SqlDataSource>

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource2" />

I set SqlDataSource2.SelectCommand  in the code behind page.

This is where I'm stuck because I never actually "create" the ADODB connection




Avatar of Anthony Perkins
nito8300,

The questioner is not using ADO but rather ADO.NET.
Well let me offer this, Should I cange what I'm doing to allow this to work? Should I fill a data table and use that as my source?
thanks acperkins. sorry kev. maybe this will help http://www.connectionstring.com/
It's as easy as this!!

Protected Sub SqlDataSource1_Selecting(ByVal Sender As Object, ByVal e As System.web.ui..webcontrols.sqldatasourceselectingeventargs) handles sqldatasource1.selecting
     e.command.commandtimeout = 0
end sub

Thanks for heading me in the right direction!

You are welcome.