Jim DeMarco
Jdemarco at hudsonhealthplan.org
Fri Mar 10 10:28:44 CST 2006
Bud,
Here's a couple of things to try.
Your reference to the File Name argument might need to be typed in like
this:
rec.Open "Select * from [Orders] ", "File Name =
'C:\B\A\x.udl';"
Or you can explictly create your connection like this:
Dim oCnn As ADODB.Connection
Dim sFileNamePath As String
Dim rs As ADODB.Recordset
sFileNamePath = "C:\B\A\x.udl"
strProvider = "Microsoft.Jet.OLEDB.4.0;Data Source=" & sFileNamePath
_
& ";Persist Security Info=False"
oCnn.Provider = strProvider
oCnn.Open
rs.Open "Select * from [Orders] ", oCnn
HTH,
Jim DeMarco
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Bud Goss
Sent: Friday, March 10, 2006 9:58 AM
To: Access Group
Subject: [AccessD] ADO recordsets and connection objects
I am trying to learn the basics of ADO recordsets and connections.
So far, I have been unable to get to first base. The two methods
listed below give me the following error:
Run-time error'-2147467259(80004005)
[Microsoft][ODBC Driver Manager] Data source name not found and no
default driver specified
First attempt with udl file:
Public Sub MyADOTest01()
Dim rec As ADODB.Recordset
Set rec = New ADODB.Recordset
rec.Open "Select * from [Orders] ", "File Name = C:\B\A\x.udl"
rec.CursorLocation = adUseClient
rec.LockType = adlockBatchOptimistic
MsgBox "OPEN HAS OCCURED " & rec!Customer
End Sub
Second attempt without udl file"
Public Sub MyADOTest02()
Dim rec As ADODB.Recordset
Set rec = New ADODB.Recordset
rec.Open "Select * from [Orders]", "File Name = C:\B\A\Northwind.mdb"
rec.CursorLocation = adUseClient
rec.LockType = adlockBatchOptimistic
MsgBox "OPEN HAS OCCURED " & rec!Customer
rec.activeconnection.Close
End Sub
C:\B\A\ .... Contains x.udl and Northwind.mdb
x.udl points to C:\B\A\Northwind.mdb and has MicrosoftJet 4.0 OLE
Provider specified
Subs are contained in another Access 2003 database that is located in
C:\B\A_Access_Tr
This database does have the reference
Microsoft ActiveX data Objects 2.1 Llibrary
Any help would be appreciated.
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
***********************************************************************************
"This electronic message is intended to be for the use only of the named recipient, and may contain information from Hudson Health Plan (HHP) that is confidential or privileged. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or use of the contents of this message is strictly prohibited. If you have received this message in error or are not the named recipient, please notify us immediately, either by contacting the sender at the electronic mail address noted above or calling HHP at (914) 631-1611. If you are not the intended recipient, please do not forward this email to anyone, and delete and destroy all copies of this message. Thank You".
***********************************************************************************