Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default ADODB Timeout

I'm trying to use the following ADODB connection string to retrieve a dozen
records from a MS SQL Server database. Everytime I run the routine, I get a
Timeout Expired error even though I'm using the ConnectionTimeout = 0 in my
connection string.

Any thoughts as to why this is happening?

TIA

Mark


Private Sub Test()

GetData "11/30/2005"

End Sub

Public Sub GetData(ByVal dtEnd As Date)

Dim Cnxn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strCnxn As String
Dim strSQL As String

' Open connection
strCnxn = "Provider=SQLOLEDB;Data Source=MY_SRVR;Initial
Catalog=MY_DB;User Id=MY_UID;Password=MY_PWD;"
Set Cnxn = New ADODB.Connection
Cnxn.CursorLocation = adUseClient
Cnxn.ConnectionTimeout = 0
Cnxn.Open strCnxn

'SQL to call from db
Set rs = New ADODB.Recordset
strSQL = "SELECT * FROM dbo.fnMetrics('" _
& Format(dtEnd, "mm/dd/yyyy") & "')"

rs.Open strSQL, Cnxn, adOpenStatic, adLockReadOnly, adCmdText

Range("Metrics_Data").CopyFromRecordset rs

rs.Close
Cnxn.Close

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default ADODB Timeout

Never mind I figured it out by adding the following command code. Apparently
the command timeout is the important one, not the connection timeout.

Set cmd = New ADODB.Command
cmd.ActiveConnection = Cnxn
cmd.CommandTimeout = 0
cmd.CommandText = strSQL
cmd.CommandType = adCmdText

Set rs = cmd.Execute




"MChrist" wrote:

I'm trying to use the following ADODB connection string to retrieve a dozen
records from a MS SQL Server database. Everytime I run the routine, I get a
Timeout Expired error even though I'm using the ConnectionTimeout = 0 in my
connection string.

Any thoughts as to why this is happening?

TIA

Mark


Private Sub Test()

GetData "11/30/2005"

End Sub

Public Sub GetData(ByVal dtEnd As Date)

Dim Cnxn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strCnxn As String
Dim strSQL As String

' Open connection
strCnxn = "Provider=SQLOLEDB;Data Source=MY_SRVR;Initial
Catalog=MY_DB;User Id=MY_UID;Password=MY_PWD;"
Set Cnxn = New ADODB.Connection
Cnxn.CursorLocation = adUseClient
Cnxn.ConnectionTimeout = 0
Cnxn.Open strCnxn

'SQL to call from db
Set rs = New ADODB.Recordset
strSQL = "SELECT * FROM dbo.fnMetrics('" _
& Format(dtEnd, "mm/dd/yyyy") & "')"

rs.Open strSQL, Cnxn, adOpenStatic, adLockReadOnly, adCmdText

Range("Metrics_Data").CopyFromRecordset rs

rs.Close
Cnxn.Close

End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
TImeIn-TimeOut-TimeIn-TimeOut-HoursWorked ChefBoiRD Excel Worksheet Functions 3 September 20th 05 10:01 AM
Timeout tcbootneck Excel Programming 1 July 15th 05 11:48 AM
Timeout Error ibeetb Excel Programming 2 November 4th 04 09:20 AM
automation timeout youxing Excel Programming 1 September 13th 04 04:06 AM
Timeout problems DavidC[_2_] Excel Programming 2 August 19th 04 02:09 AM


All times are GMT +1. The time now is 06:22 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"