Solved

Timeout expired for executing ms-sql store procedure?

Posted on 2002-07-10
7
380 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
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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 142

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now