SQL timeout error

M

Martin Eyles

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
 
M

Marina Levit [MVP]

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.
 
S

sloan

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.
 
G

Guest

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
 
G

Guest

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;
}
 
Joined
Jul 22, 2011
Messages
1
Reaction score
0
Having Problem Time out error

in my all client machines having problem of Time out error .how can i fix in sql server 2000
thanx
jarnail
 
Joined
Nov 19, 2008
Messages
1
Reaction score
0
also in vb code

Protected Sub SqlDataSource1_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles SqlDataSource1.Selecting
e.Command.CommandTimeout = 300
End Sub

thanks...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top