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
0
hesCommented:
Dim ws As Workspace
Dim db As Database
Set db = ws.OpenDatabase("DataBase Name",UID="UserId",PWD="Password)      
0
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
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy 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.
0
rovermCommented:
It should !
If you test the connection, does it test OK ?
0
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)
0

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)

0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.