Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > SQL timeout error

Reply
Thread Tools

SQL timeout error

 
 
Martin Eyles
Guest
Posts: n/a
 
      07-31-2006
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



 
Reply With Quote
 
 
 
 
Gary
Guest
Posts: n/a
 
      07-31-2006
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:
> 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


 
Reply With Quote
 
 
 
 
Marina Levit [MVP]
Guest
Posts: n/a
 
      07-31-2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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
>
>
>



 
Reply With Quote
 
Martin Eyles
Guest
Posts: n/a
 
      07-31-2006
Thanks,
Works perfectly,
Martin

"Gary" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> 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:
>> 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

>



 
Reply With Quote
 
sloan
Guest
Posts: n/a
 
      07-31-2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>
>



 
Reply With Quote
 
=?Utf-8?B?amVmZiB0dQ==?=
Guest
Posts: n/a
 
      09-20-2006
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:

> 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:
> > 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

>
>

 
Reply With Quote
 
=?Utf-8?B?amVmZiB0dQ==?=
Guest
Posts: n/a
 
      09-20-2006
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:

> 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:
>
> > 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:
> > > 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

> >
> >

 
Reply With Quote
 
jarnailkainth jarnailkainth is offline
Junior Member
Join Date: Jul 2011
Posts: 1
 
      07-22-2011
in my all client machines having problem of Time out error .how can i fix in sql server 2000
thanx
jarnail
 
Reply With Quote
 
yumil yumil is offline
Junior Member
Join Date: Nov 2008
Posts: 2
 
      10-06-2011
Protected Sub SqlDataSource1_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEv entArgs) Handles SqlDataSource1.Selecting
e.Command.CommandTimeout = 300
End Sub

thanks...
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
sql timeout from web application problem (works good in sql server dave ASP .Net 2 12-04-2008 02:42 PM
SQL Reference, SQL Queries, SQL help ecoolone ASP .Net 0 01-03-2008 10:58 AM
/usr/local/lib/ruby/1.8/timeout.rb:54:in `rbuf_fill': execution expired (Timeout::Error) vishnu Ruby 0 05-31-2006 11:08 AM
/usr/local/lib/ruby/1.8/timeout.rb:54:in `rbuf_fill': execution expired (Timeout::Error) vishnu Ruby 0 05-31-2006 11:08 AM
Timeout::timeout and Socket timeout Mark Probert Ruby 1 10-06-2004 09:30 AM



Advertisments