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?
ASP.NETMicrosoft SQL Server

Avatar of undefined
Last Comment
Anthony Perkins
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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of kevlause
kevlause

ASKER

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.
Avatar of kevlause
kevlause

ASKER

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?
Avatar of nito8300
nito8300
Flag of United States of America image

thanks acperkins. sorry kev. maybe this will help http://www.connectionstring.com/
Avatar of kevlause
kevlause

ASKER

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.
Microsoft SQL Server
Microsoft SQL Server

Microsoft SQL Server is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.SQL Server is available in multiple versions, typically identified by release year, and versions are subdivided into editions to distinguish between product functionality. Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning.

171K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo