Using ADO in the same mdb thats a secured access database

D

Dan D

I am trying to use ADO with Access 2000 to acess data in the tables in the
same mdb database.

Here is what I had...

Set m_cn = New ADODB.Connection
m_cn.ConnectionString = CurrentProject.BaseConnectionString
m_cn.Open

I thought this would give the proper connection string and everything would
be fine. I guess it would work if it wasn't a secured database. Opening
the database requires a workgroup file and a username and password. Seeing
as I am already in the database is there anyway I can use ADO to connect to
the tables without having to worry about the connection strings and what
not. DAO makes it easy. ADO doesn't.

So if there is no way, how can I set the connection string to use the same
mdw workgroup file as the mdb the code is running from is using.

Again I find it silly I have to set all the connection properties seeing as
I am already inside the db I am trying to get ADO to connect to

Thanks,

Dan
 
D

Dan D

Ok, well part of that has been figured out.. I just pass in the userid and
password in the open method. The path to the mdw was included in the
connection string.

Set m_cn = New ADODB.Connection
m_cn.ConnectionString = CurrentProject.BaseConnectionString
m_cn.Open , "dba", "mypassword"

My problem is now what I run
m_cn.Open , "admin", "mypassword"


I get the following error

The database has been placed in a state by user 'admin' on machine
'1280-DEV1' that prevents it from being opened or locked.
 
D

Dirk Goldgar

Dan D said:
I am trying to use ADO with Access 2000 to acess data in the tables
in the same mdb database.

Here is what I had...

Set m_cn = New ADODB.Connection
m_cn.ConnectionString = CurrentProject.BaseConnectionString
m_cn.Open

I thought this would give the proper connection string and everything
would be fine. I guess it would work if it wasn't a secured
database. Opening the database requires a workgroup file and a
username and password. Seeing as I am already in the database is
there anyway I can use ADO to connect to the tables without having to
worry about the connection strings and what not. DAO makes it easy.
ADO doesn't.

So if there is no way, how can I set the connection string to use the
same mdw workgroup file as the mdb the code is running from is using.

Again I find it silly I have to set all the connection properties
seeing as I am already inside the db I am trying to get ADO to
connect to

I agree -- it's silly. <g> Or rather, it's unnecessary.

Set m_cn = CurrentProject.Connection

Is all you need. Unless there's something you haven't told us.
 

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