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: 1
Default change DAO code to ADO

Hello All,

I have a question, I have a function which can let me use SQL in VBA
Excel to to query with Access.

Set wrkODBC = CreateWorkspace("ODBCWorkspace", "research", "",_
dbUseODBC)
Set cn = wrkODBC.OpenConnection("", dbDriverNoPro,_ False,
"ODBC;DSN=<ABCDE;UID=hello;PWD=hello")

this works. but i want to use ADO method, so I change it into

Dim getAccess As ADODB.Connection
sConnect = "Provider=SQLOLEDB;" & "Initial Catalog=Goldfinger;" _ &
"User ID = research;" & "Password = research;"
getAccess.ConnectionString = sConnect
getAccess.Open

i dont know why, i always got a error message telling me: 91 Object
variable or With block variable not set -2147221504

or if I want to run:

Set rsData = New ADODB.Recordset
rsData.Open sSQL, sConnect, adOpenKeyset, adLockReadOnly, adCmdText

then it will tell me: -2147467259 [DBNETLIB][ConnectionOpen
(Connect()).]SQL Server does not exist or access denied. -2147221504


Can any one help me? Thanks a lot.

 
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
How do I change this code? OrlaLynch Excel Discussion (Misc queries) 1 June 11th 08 03:06 PM
VBA Code to Change the Tab Name Michael in Texas Excel Discussion (Misc queries) 1 March 28th 07 03:07 AM
VBA Code to Change the Tab Name Gary''s Student Excel Discussion (Misc queries) 0 March 28th 07 12:05 AM
VB CODE RUN ON DDE VALUE CHANGE Frank Kabel Excel Programming 1 April 1st 04 08:31 PM
Change to Code Chip Pearson Excel Programming 4 July 28th 03 10:54 PM


All times are GMT +1. The time now is 07:44 PM.

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"