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

  2. Martin Eyles

    Gary Guest

    Gary, Jul 31, 2006
    #2
    1. Advertisements

  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.
     
    Marina Levit [MVP], Jul 31, 2006
    #3
  4. Martin Eyles

    Martin Eyles Guest

    Thanks,
    Works perfectly,
    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.
     
    sloan, Jul 31, 2006
    #5
  6. Martin Eyles

    Guest 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
     
    Guest, Sep 20, 2006
    #6
  7. Martin Eyles

    Guest 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;
    }
     
    Guest, Sep 20, 2006
    #7
  8. Martin Eyles

    jarnailkainth

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

    yumil

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

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 (here). After that, you can post your question and our members will help you out.