• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 203
  • Last Modified:

VB --- Connection time Out

I have generated an SQL procedure which is having loop between several tables. When I am running this procedure from Query Analyzer result is coming perfect. But when I am calling it from VB through connection execute command it is showing error after few minutes “Error: Connection Time Out”.

Please help me how can I fix it?

Rgds.
Iqbal
0
Mehram
Asked:
Mehram
  • 2
  • 2
1 Solution
 
boyinapalliBI DeveloperCommented:
Increase the Connection TimeOut.

Example:

Private adoComp As New ADODB.Connection
adoComp .ConnectionTimeout = 600
0
 
MehramAuthor Commented:
Dear Boyinapalli

I have tried it but problem is remain un changed

Pls find below my code detail


cn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=School"
cn.ConnectionTimeout = 2000
cn.Execute "result_process2 @cyear='" & workingyear & "'"
msgbox "Done"

Runt time Error: 2147217871 Time out Expired


Awaiting for your assistant

Rgds.
Iqbal
0
 
MehramAuthor Commented:
Dear Boyinapalli

I have tried it but problem is remain un changed

Pls find below my code detail


cn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=School"
cn.ConnectionTimeout = 2000
cn.open
cn.Execute "result_process2 @cyear='" & workingyear & "'"
msgbox "Done"

Runt time Error: 2147217871 Time out Expired


Awaiting for your assistant

Rgds.
Iqbal
0
 
boyinapalliBI DeveloperCommented:
Instead of executing directly from connection, try creating the command and execute... see below:   (I am returing the results from the stored procedure to a recordset in the below example.....)

    Set cmd = New ADODB.Command
    cmd.CommandText = vsStoredProcName
    cmd.CommandType = adCmdStoredProc
    Set cmd.ActiveConnection = ActiveConn
    cmd.ActiveConnection.CursorLocation = CursorLocation
    vParameters(i) = Parameters(i).Value
    If iParameterCount >= 0 Then
        Set rsTemp = cmd.Execute(, vParameters)
    Else
        Set rsTemp = cmd.Execute
    End If
    Set ExecuteRetrievalStoredProc = rsTemp
    rbSuccess = True
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now