SQL timeout error

Discussion in 'ASP .Net' started by Martin Eyles, Jul 31, 2006.

  1. Martin Eyles

    Martin Eyles Guest

    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, Jul 31, 2006
    #1
    1. Advertising

  2. Martin Eyles

    Gary Guest

    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/library/system.data.sqlclient.sqlcommand.commandtimeout.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
    Gary, Jul 31, 2006
    #2
    1. Advertising

  3. 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" <> wrote in message
    news:...
    >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], Jul 31, 2006
    #3
  4. Martin Eyles

    Martin Eyles Guest

    Thanks,
    Works perfectly,
    Martin

    "Gary" <> wrote in message
    news:...
    > 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/library/system.data.sqlclient.sqlcommand.commandtimeout.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

    >
    Martin Eyles, Jul 31, 2006
    #4
  5. Martin Eyles

    sloan Guest

    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" <> wrote in message
    news:...
    > 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, Jul 31, 2006
    #5
  6. 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/library/system.data.sqlclient.sqlcommand.commandtimeout.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

    >
    >
    =?Utf-8?B?amVmZiB0dQ==?=, Sep 20, 2006
    #6
  7. 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/library/system.data.sqlclient.sqlcommand.commandtimeout.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

    > >
    > >
    =?Utf-8?B?amVmZiB0dQ==?=, Sep 20, 2006
    #7
  8. Martin Eyles

    jarnailkainth

    Joined:
    Jul 22, 2011
    Messages:
    1
    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
    jarnailkainth, Jul 22, 2011
    #8
  9. Martin Eyles

    yumil

    Joined:
    Nov 19, 2008
    Messages:
    1
    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...
    yumil, Oct 6, 2011
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Milsnips
    Replies:
    6
    Views:
    2,017
    Milsnips
    Nov 17, 2006
  2. dave
    Replies:
    2
    Views:
    1,919
    daveh551
    Dec 4, 2008
  3. Mark Probert

    Timeout::timeout and Socket timeout

    Mark Probert, Oct 6, 2004, in forum: Ruby
    Replies:
    1
    Views:
    1,271
    Brian Candler
    Oct 6, 2004
  4. vishnu
    Replies:
    0
    Views:
    341
    vishnu
    May 31, 2006
  5. vishnu
    Replies:
    0
    Views:
    194
    vishnu
    May 31, 2006
Loading...

Share This Page