Solved

Timeout expired for executing ms-sql store procedure?

Posted on 2002-07-10
7
412 Views
Last Modified: 2012-06-21
I receive time out error message for executing ms-sql store procedure message (Timeout expired -2147217871) using ADODB.Connection

How to I increase Time Out interval?
0
Comment
Question by:AStronus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 

Expert Comment

by:itmelo
ID: 7144697
For a Connection:
oConn.ConnectionTimeout = 30
For a Command:
oCmd.CommandTimeout = 30
0
 
LVL 1

Accepted Solution

by:
gallo47 earned 200 total points
ID: 7144703
This is the code I use for stored procedures:

Dim cn As ADODB.Connection
Dim RS As ADODB.Recordset
Dim cmd As ADODB.Command

Set cn = New ADODB.Connection
cn.Open "Provider=SQLOLEDB.1;User ID=uid;Password=pw;Initial Catalog=dbname;Data Source=server"

Set cmd = New ADODB.Command

With cmd
     .ActiveConnection = cn
     .CommandText = "usp_SPName"
     .CommandType = adCmdStoredProc
     .Parameters("@Param1") = SomeValue
     .CommandTimeout = 300  'This is where the timeout is set
End with

Set RS = cmd.Execute
0
 
LVL 1

Expert Comment

by:gallo47
ID: 7144705
Sorry itmelo beat me to it
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

Author Comment

by:AStronus
ID: 7144792
I'm using ConnectionString
and set
oConn.ConnectionString="...."
oConn.ConnectionTimeout=900000000
oConn.Open
recordset=OConn.Execute("....")
but I still receive Time out
:(
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 7145083
Set the CommandTimeout not the ConnectionTimeout property.  In other words:
oConn.ConnectionString="...."
oConn.CommandTimeout = 0  'Infinite timeout
oConn.Open
recordset=OConn.Execute("....")

Anthony
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 7145471
If the stored procedure times out, you might first check how much time it needs to execute (using query analyser). If there it takes only seconds, then you need to check why the connection takes so much time, otherwise start optimizing the proc

CHeers
0
 

Author Comment

by:AStronus
ID: 7146455
ConnectionTimeout doesn't work for me, as I change ConnectionString to ADODB.Command and set Time out it's work great.  Sorry, all answer is correct but I can give pts to 1 person only.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question