Querying an Access DB with security

How do I run an SQL query (from VB) on an Access database when I have set a security password on the database - I don't seem to be able to open a record set
DavidDunnAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

johnny6Commented:
I think you will find what you are looking for here:

http://www.microsoft.com/data/ado/adotechinfo/dao2ado.htm
hesCommented:
Dim ws As Workspace
Dim db As Database
Set db = ws.OpenDatabase("DataBase Name",UID="UserId",PWD="Password)      
rovermCommented:
If you're using VB6:
Add a DataEnvironment, add a connection, set the properties (like the password), then in code:

Dim rs As New ADODB.Recordset
DataEnvironment1.Connection1.Open
Set rs = DataEnvironment1.Connection1.Execute("SELECT * FROM MyTable")

Don't forget to close the connection after using it and flushing the recordset !

Good luck !

RoverM
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

DavidDunnAuthor Commented:
I don't have a user id, I've just set a password on the database. The above code doesn't work.
rovermCommented:
It should !
If you test the connection, does it test OK ?
CdCopyCommented:
this code should work, if you haven't setup a userID then by default its ADMIN.

Open the database and then open the LDB file with notepad, you will see the userID and the machine name.


Set db = ws.OpenDatabase("DataBase Name",UID="Admin",PWD="Password)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hesCommented:
With no userid try

Dim ws As Workspace
Dim db As Database
Set db = ws.OpenDatabase("DataBase Name";UID=;PWD="Password)

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.