ADO Connection

  • Thread starter Craig Henderson
  • Start date
C

Craig Henderson

I am trying to create an ADODB.Connection to the current
database in order to have finer control over table
updates.

In DAO, this was possible by setting a "Database"
variable to "CurrentDb", and then using the
db.OpenRecordset method with an appropriate SQL
statement. I have not been able to duplicate this
functionality with ADO, as I get a message indicating
that "Admin" has placed my Access file into a state the
prohibits opening or locking when I try to establish the
connection.

Any assistance in greatly appreciated.
 
J

Juan M. Afan de Ribera

If you are using Access 2000 or 2002 (or 2003), instead of CurrentDb you
have to use CurrentProject.Connection. i.e.

Dim con As ADODB.Connection
Dim rst As ADODB.Recordset

Set con = CurrentProject.Connection
Set rst = New ADODB.Recordset

rst.Open "SELECT * FROM customers", con

' ....
' do something
' ....

rst.Close
Set rst = Nothing
Set con = Nothing

if you want some more information in migrating from DAO to ADO, have a look
at this article

http://tinyurl.com/byxn

HTH

--
Saludos desde Barcelona
Juan M. Afan de Ribera
<MVP Ms Access>
http://www.juanmafan.tk
http://www.clikear.com/webs4/juanmafan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top