LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 441
Default Make table query works intermittently

I am using Office 2003 on Windows XP.

I am running the following code. This is running from a standard code module
in Excel, querying Oracle, and making a table into an Access DB. The problem
is, sometimes it runs fine, other times I get "ODBC Call Fails" error:

Dim sSQL as String
Dim sConnect as String
Dim sFullNameDB as String

sConnect = "PROVIDER=MSDASQL.1;DRIVER={ORACLE ODBC
DRIVER};SERVER=MyServer;DBQ=MyDBQ;UID=***;PWD=***; "

sFullNameDB = "C:\Temp\MyAccessDB.mdb"

sSQL = "SELECT "
sSQL = sSQL & "[GL].ACCTNO, "
sSQL = sSQL & "[GL].ACCOUNT_DESC, "
....<OTHER SQL - REMOVED FOR THIS EXAMPLE...
sSQL = sSQL & "INTO "
sSQL = sSQL & "[IMPORT] "
sSQL = sSQL & "FROM "
sSQL = sSQL & "[ODBC;" & sConnect & "].[APPS.GLBALVW] AS [GL] "
sSQL = sSQL & "WHERE "
sSQL = sSQL & "[GL].PERIOD_NAME IN ('Sep-03', 'Sep-04') AND "
sSQL = sSQL & "[GL].FUND BETWEEN '800' AND '999' AND "
sSQL = sSQL & "[GL].ACCOUNT BETWEEN '0000' AND '8999';"

Set cnADO = New ADODB.Connection
cnADO.CommandTimeout = 0
cnADO.CursorLocation = adUseClient
cnADO.Provider = "Microsoft.Jet.OLEDB.4.0"
cnADO.ConnectionString = sFullNameDB
cnADO.Open
cnADO.Execute sSQL
cnADO.Close
Set cnADO = Nothing

Please note I have timeout set to zero.
Any help appreciated. Thanks in advance.
 
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
Make a product that works msnyc07 Excel Worksheet Functions 12 February 11th 10 01:34 AM
Make table query will work in datasheet view but will not make tab WildlyHarry Excel Discussion (Misc queries) 0 August 28th 07 03:06 PM
Make Table Query into Text File XP Excel Programming 0 September 14th 05 03:38 PM
Use Excel to make an update query to another database table? Reigning in Seattle Excel Discussion (Misc queries) 2 April 14th 05 06:25 PM
Copy recordset from an Access "make table" query Laurie[_4_] Excel Programming 1 February 5th 04 09:45 AM


All times are GMT +1. The time now is 10:29 AM.

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

About Us

"It's about Microsoft Excel"