Connecting Tech Pros Worldwide Forums | Help | Site Map

SQL timeout error

Martin Eyles
Guest
 
Posts: n/a
#1: Jul 31 '06
I am trying to perform a very long query on an MSSQL database, using
ASP.NET, and making the code behind in VB.NET. I have been receiving timeout
error, so I thought I would add Connect Timeout to my connection string.
However this appears to have no effect. The connection string is set up as
follows

Dim conn As New SqlClient.SqlConnection("Data Source=serverName; User
ID=userName; Password=password; Connect Timeout=9999")

Any ideas why this isn't changing the timeout?

Thanks,
Martin




Gary
Guest
 
Posts: n/a
#2: Jul 31 '06

re: SQL timeout error


Martin,

I think the most accepted method of doing this is through the
CommandTimeout property of the SqlCommand object. Set it to 0 for an
infinite timeout. Here's the msdn link:

http://msdn2.microsoft.com/en-us/lib...ndtimeout.aspx

Hope this helps,
Gary

Martin Eyles wrote:
Quote:
I am trying to perform a very long query on an MSSQL database, using
ASP.NET, and making the code behind in VB.NET. I have been receiving timeout
error, so I thought I would add Connect Timeout to my connection string.
However this appears to have no effect. The connection string is set up as
follows
>
Dim conn As New SqlClient.SqlConnection("Data Source=serverName; User
ID=userName; Password=password; Connect Timeout=9999")
>
Any ideas why this isn't changing the timeout?
>
Thanks,
Martin
Marina Levit [MVP]
Guest
 
Posts: n/a
#3: Jul 31 '06

re: SQL timeout error


What you are setting is the connection timeout. That means how long the
connection waits while trying to connect to the database server before
giving up.

This is in no way related to the timeout when executing commands. Not sure
why you thought it would be.

Follow Gary's advice for setting the CommandTimeout to control the timeout
while executing commands.

"Martin Eyles" <martin.eyles@NOSPAMbytronic.comwrote in message
news:12cs37c14oriqe0@corp.supernews.com...
Quote:
>I am trying to perform a very long query on an MSSQL database, using
ASP.NET, and making the code behind in VB.NET. I have been receiving
timeout
error, so I thought I would add Connect Timeout to my connection string.
However this appears to have no effect. The connection string is set up as
follows
>
Dim conn As New SqlClient.SqlConnection("Data Source=serverName; User
ID=userName; Password=password; Connect Timeout=9999")
>
Any ideas why this isn't changing the timeout?
>
Thanks,
Martin
>
>
>

Martin Eyles
Guest
 
Posts: n/a
#4: Jul 31 '06

re: SQL timeout error


Thanks,
Works perfectly,
Martin

"Gary" <ggalehouse@neo.rr.comwrote in message
news:1154354946.485036.273370@m79g2000cwm.googlegr oups.com...
Quote:
Martin,
>
I think the most accepted method of doing this is through the
CommandTimeout property of the SqlCommand object. Set it to 0 for an
infinite timeout. Here's the msdn link:
>
http://msdn2.microsoft.com/en-us/lib...ndtimeout.aspx
>
Hope this helps,
Gary
>
Martin Eyles wrote:
Quote:
>I am trying to perform a very long query on an MSSQL database, using
>ASP.NET, and making the code behind in VB.NET. I have been receiving
>timeout
>error, so I thought I would add Connect Timeout to my connection string.
>However this appears to have no effect. The connection string is set up
>as
>follows
>>
>Dim conn As New SqlClient.SqlConnection("Data Source=serverName; User
>ID=userName; Password=password; Connect Timeout=9999")
>>
>Any ideas why this isn't changing the timeout?
>>
>Thanks,
> Martin
>

sloan
Guest
 
Posts: n/a
#5: Jul 31 '06

re: SQL timeout error


Yes,

You getting the settings wrong.

Connect Timeout is the amount of time to ~find the server.

Command Timeout is the amount of time.. for instance, a proc runs before
timing out.

You need Command Timeout.




"Martin Eyles" <martin.eyles@NOSPAMbytronic.comwrote in message
news:12cs37c14oriqe0@corp.supernews.com...
Quote:
I am trying to perform a very long query on an MSSQL database, using
ASP.NET, and making the code behind in VB.NET. I have been receiving
timeout
Quote:
error, so I thought I would add Connect Timeout to my connection string.
However this appears to have no effect. The connection string is set up as
follows
>
Dim conn As New SqlClient.SqlConnection("Data Source=serverName; User
ID=userName; Password=password; Connect Timeout=9999")
>
Any ideas why this isn't changing the timeout?
>
Thanks,
Martin
>
>
>

jeff tu
Guest
 
Posts: n/a
#6: Sep 20 '06

re: SQL timeout error


I'm having the same problem, but in my case, I'm using the default Database
adapter, not the Object adapter (middle tier). Hence, I don't see a way to
get a hold of the CommandTimeout property since I'm not the one that is
creating the SqlCommand object.

Am I stuck or is there another way? I'm not inclined to change my code to
use Object adapter at this point.

Thanks,
Jef

"Gary" wrote:
Quote:
Martin,
>
I think the most accepted method of doing this is through the
CommandTimeout property of the SqlCommand object. Set it to 0 for an
infinite timeout. Here's the msdn link:
>
http://msdn2.microsoft.com/en-us/lib...ndtimeout.aspx
>
Hope this helps,
Gary
>
Martin Eyles wrote:
Quote:
I am trying to perform a very long query on an MSSQL database, using
ASP.NET, and making the code behind in VB.NET. I have been receiving timeout
error, so I thought I would add Connect Timeout to my connection string.
However this appears to have no effect. The connection string is set up as
follows

Dim conn As New SqlClient.SqlConnection("Data Source=serverName; User
ID=userName; Password=password; Connect Timeout=9999")

Any ideas why this isn't changing the timeout?

Thanks,
Martin
>
>
jeff tu
Guest
 
Posts: n/a
#7: Sep 20 '06

re: SQL timeout error


Never mind. I found the solution in aspnet section. If anyone is interested,
the answer comes from Walter Wang:

You can set the select command's timeout value in SqlDataSource's Selecting
event:

protected void SqlDataSource1_Selecting(object sender,
SqlDataSourceSelectingEventArgs e)
{
e.Command.CommandTimeout = 30;
}



"jeff tu" wrote:
Quote:
I'm having the same problem, but in my case, I'm using the default Database
adapter, not the Object adapter (middle tier). Hence, I don't see a way to
get a hold of the CommandTimeout property since I'm not the one that is
creating the SqlCommand object.
>
Am I stuck or is there another way? I'm not inclined to change my code to
use Object adapter at this point.
>
Thanks,
Jef
>
"Gary" wrote:
>
Quote:
Martin,

I think the most accepted method of doing this is through the
CommandTimeout property of the SqlCommand object. Set it to 0 for an
infinite timeout. Here's the msdn link:

http://msdn2.microsoft.com/en-us/lib...ndtimeout.aspx

Hope this helps,
Gary

Martin Eyles wrote:
Quote:
I am trying to perform a very long query on an MSSQL database, using
ASP.NET, and making the code behind in VB.NET. I have been receiving timeout
error, so I thought I would add Connect Timeout to my connection string.
However this appears to have no effect. The connection string is set up as
follows
>
Dim conn As New SqlClient.SqlConnection("Data Source=serverName; User
ID=userName; Password=password; Connect Timeout=9999")
>
Any ideas why this isn't changing the timeout?
>
Thanks,
Martin
Closed Thread