Connecting to ADO database

S

Sebastian

I'm using the following code to connect to an access 2000
database.
(with reference to adodb)
Public DBvar As New ADODB.Connection()
DBvar.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=Data.mdb", "userID", "Pass")


Previously I was connecting with just
DBvar.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=Data.mdb")
and it was working fine because I had not set a password
for the database. Then I set a password and now using:
DBvar.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=Data.mdb", "Admin", "Pass")
and I get this error:
"Cannot start your application. The workgroup information
file is missing or opened exclusively by another user."
When I set the password I had to open the database file
exclusively for it to set it. Does that have anything to
do with it?
What does this error mean? How do I fix this?

Thank you

Seb
 
C

Cor Ligthert

Hi Sebastian,

I think that the best thing to do for specific Classic problems is to ask it
in a VB classic newsgroup.

microsoft.public.vb

I think you have more change to find information there because in VB.net is
mostly used Ado.net.

Cor
 
T

Tarren

For one thing it looks as though your connection string is structured
incorrectly. Make a text file on the desktop, rename it to something.udl
and create your connection string in the GUI. Then open the udl in notepad
and cut and pasted your connection string.

Is this VB6? If it is .NET you should be using oledb namespace for
connecting to Access mdb. Regardless of whether it is VB6 or .NET, take a
look at your connection string.
 
S

Sebastian

How do I need to change the code to connect using ado .net
with username and password?
Do I remove the reference to adodb? Do I add any other
references?

Thanks

Sebastian
 
C

Cor Ligthert

Hi Sebastian,

When you use AdoNet you cannot use the recordset, however filling a dataset
can be as simple as this

dim conn as new OleDb.OleDbconnection(www.connectionstrings.com)
dim ds as new dataset
dim da as new OleDB.OleDbDataAdapter("Select * From Mytable",conn)
da.fill(ds)

And your dataset is filled.

I hope this give you an idea?

Cor
 

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