Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2004

    Unhappy Unanswered: Query timeout in Visual Basic

    Hello there,

    I am programming with visual basic and I have a large query wich takes too long for execution. After 30 seconds I get a timeout error.

    Is there any way to raise the timeout to 90 seconds or something.

    I'm using the following connection string to connect to the database.

    Provider=SQLOLEDB.1;Connect Timeout=2;Password=****;Persist Security Info=True;User ID=user;Initial Catalog=test;Data Source=sqlserver

    thank you

  2. #2
    Join Date
    Mar 2004
    Here is some sample code.

    On Error Resume Next
    Set cn = New ADODB.Connection
    cn.Provider = "SQLOLEDB"
    cn.Properties("Initial Catalog").Value = "DatabaseName"
    cn.Properties("Data Source").Value = "ServerName"
    cn.Properties("Connect Timeout").Value = 90
    cn.Properties("General Timeout").Value = 90
    cn.Properties("Persist Security Info").Value = False
    cn.ConnectionTimeout = 90
    cn.CommandTimeout = 90

    Download for FREE the ADO/DAO Data Controls that makes life EASIER developing database applications in: VB, FoxPro, Access, VC++, .NET etc... Navigate, Add New, Delete, Update, Search, Undo and Save your changes. Supports Disconnected Recordsets and Transactions!

    Or try our Ask An Expert service to answer any of your questions!

  3. #3
    Join Date
    Aug 2004

    Timeout from VB to Syabase not working!

    When I connect to Sybase from VB. I want to display a timeout error message. But it goes on till it gets the data. How can I stop fetching & force an error msg.
    Here is my code.
    Pl HELP!!!!!!!

    Dim sCNN As String
    Dim sSQL As String
    Dim conOms As ADODB.Connection
    Dim rsOms As ADODB.Recordset
    Dim oCm As ADODB.Command

    Set conOms = New ADODB.Connection

    sCNN = "Provider=MSDASQL.1;Password='abc';Persist Security Info=False;User ID='xyz';Initial Catalog='dbeg';Data Source='testdsn'"
    sSQL = "Select * from emp"

    With conOms
    .ConnectionString = sCNN
    .Properties("Connect Timeout").Value = 1
    .Properties("General Timeout").Value = 1
    .Properties("Persist Security Info").Value = False
    .ConnectionTimeout = 1
    .CommandTimeout = 1


    End With

    Set oCm = New ADODB.Command
    With oCm
    Set .ActiveConnection = conOms
    .CommandText = sSQL
    .CommandType = adCmdText
    .CommandTimeout = 1

    End With

    Set rsOms = New ADODB.Recordset
    With rsOms
    .CursorLocation = adUseClient
    .Open oCm
    End With

    MsgBox rsOms.RecordCount

    Exit Sub

    MsgBox Prompt:=Err.Number & " " & Err.Description, Title:="Data Retrieval Error", Buttons:=vbExclamation
    Exit Sub
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts