PDA

View Full Version : Is this a timeout issue?



BBM
07-23-2010, 04:01 AM
Hi folks,

Can anybody help me out?

The following snippet populates a sheet with a Querytable. The stored proc runs in SQL Server fine (albeit in aprox 30 secs), and the connection is also valid, being used elsewhere in my code for other stored procs.

However.... when this executes it thinks about if for around 20 secs then displays:

"Run-time error '1004': General ODBC Error"

heres the code:



Sheets("MySheet").Cells.Clear
Range("A1").Select
OB = "123"
SQLString = "EXEC MyStoredProc '" & OB & "'"
Conn = "ODBC;DRIVER=SQL Server;SERVER=nnn.nnn.nnn.nnn;UID=abc;APP=Microsoft Office 2003;WSID=ABC123;DATABASE=aDB;Connection Timeout=0;Trusted_Connection=Yes;"

With ActiveSheet.QueryTables.Add(Connection:=Conn, Destination:=Range("A1"), Sql:=SQLString)
.Refresh BackgroundQuery:=False ' ** fails here **
End With


Many THanks!