vb - sql server 2000 timeout

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jamesd0142
    Contributor
    • Sep 2007
    • 471

    vb - sql server 2000 timeout

    im using this connection string:

    [code=vbnet]
    Con = New OleDb.OleDbConn ection("Provide r=sqloledb;Data Source=Datadiss 3;Initial Catalog= " & Database & ";" & "User ID=username;Pas sword=password; connect timeout=0")
    [/code]

    and i get error connection timed out.

    Why is the connect timeout=0 not working?

    Or can any one suggest anything?

    Thanks

    James
  • dip_developer
    Recognized Expert Contributor
    • Aug 2006
    • 648

    #2
    Originally posted by jamesd0142
    im using this connection string:

    [code=vbnet]
    Con = New OleDb.OleDbConn ection("Provide r=sqloledb;Data Source=Datadiss 3;Initial Catalog= " & Database & ";" & "User ID=username;Pas sword=password; connect timeout=0")
    [/code]

    and i get error connection timed out.

    Why is the connect timeout=0 not working?

    Or can any one suggest anything?

    Thanks

    James
    hi james,
    if you wish to use Connection Timeout in your string then keep in mind the following.....
    You have to set Timeout settings at three level. and these all will work together.

    First:
    In SQL Server enterprise manager, in database property set query time out to 0, It's default vaule is 600.

    Second:
    In your connection string add "Connection Timeout = 0"

    Third:
    When you executing your stored procedure or query, that time you also need to set SqlCommand's CommandTimeout to 0.
    Ex. : cmdExecute.Comm andTimeout = 0;
    and keep in mind Connection timeout is---->
    The length of time (in seconds) to wait for a connection to the server before terminating the attempt and generating an error.its default value is 15.
    A value of 0 indicates no limit, and should be avoided in a ConnectionStrin g, because an attempt to connect will wait indefinitely.

    Comment

    • jamesd0142
      Contributor
      • Sep 2007
      • 471

      #3
      Thanks for the reply.

      I was advised to create an index in my database to speed up the query. This worked wonders and i no longer get the timed out error.

      James

      Comment

      Working...