PDA

Click to See Complete Forum and Search --> : Connect ADO to db with password


JenniferW
Jun 5th, 2000, 11:01 PM
Hi,

I've been struggling with this problem for awhile and was wondering if some of you VB/database gurus out there could help me out with it.

I am trying to connect my ADO control to an Access 97 db that has a password. The goal is to be able to connect to this Access db with my application on machines that don't necessarily have Access installed.

I'm trying to use the connection string property of the ADO control and Microsoft Jet 3.51 OLE DB Provider. When the db doesn't have a password I have no trouble connecting to it with the following code:

adoTestDB.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51; " & "Persist Security Info=False;" & "Data Source=" & App.Path & "\Test.mdb"


However, when the db has a password, I start running into problems. When I enter the following information in the Data Link Properties window:
I. Provider:
Microsoft Jet 3.51 OLE DB Provider
II. Connection:
1. I select the db "test.mdb"
2. I enter the username ("Admin") and the password

When I Test the connection I get the error:
"Test connection failed because of an error initializing provider. Can't start your application. The workgroup info file is missing or opened exclusively by another user."

The thing is I have the system.mdw file on my system in C:\Windows\System (just where Access created it) and I don't have the db opened (I don't even have Access opened).

Do you have any idea where I could be going wrong on this?

As an extra tidbit, I have been able to successfully connect to the db with a password using the OLE Provider for ODBC Drivers, but when I go to install my application on the NT machine without Access 97, I get an error when it tries to open the db.

What do you think?

Thank you in advance,
Jen

Chris
Jun 6th, 2000, 12:37 AM
Just refer to this Thread (http://forums.vb-world.net/showthread.php?threadid=17591)
where I've replied.

JenniferW
Jun 6th, 2000, 02:05 AM
Thank you Chris! I had reviewed quite a few messages on this discussion board about connecting to a password protected db but only those in the Database forum so I had missed that message which was exactly my question (though worded much more succinctly!). I'll give your suggestion a try right now.

Also, I was able to get the ODBC provider to work -- I think the quotation marks required in the extended properties tripped me up. Here's the code that worked:

adoTestDB.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=True;Extended Properties=" & Chr(34) & "DBQ=" & App.Path & DB_FILE_NAME & ";DefaultDir=" & App.Path & ";Driver={Microsoft Access Driver (*.mdb)};DriverId=25;FIL=MS Access;ImplicitCommitSync=Yes;MaxBufferSize=512;MaxScanRows=8;PageTimeout=5;PWD=" & PASSWORD & ";SafeTransactions=0;Threads=3;UID=admin;UserCommitSync=Yes;" & Chr(34)

Where DB_FILE_NAME and PASSWORD are constants.

Since this is pretty new to me when I got the error message that stated:
"[Microsoft][ODBC Microsoft Access 97 Driver] '(unknown)' isn't a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides."
I thought that using the ODBC provider wasn't going to work out on a machine without Access installed. I don't know why I thought that?!

Anyway, thanks!

Jen

ejbrown
Dec 3rd, 2002, 04:30 PM
Hi, For those using the data environment and having this problem like me. (VB6)

Open up the properties for the connection.

Select the ALL tab and look for where it says
"Jet OLEDB:DataBase Password " .

then click the button that says edit the value.

Then enter the proper password.

Then select the Connection Tab and select the proper UserID (Admin) and I left the password blank here.

Then test the connection and all is well.

I guess there is different levels of passwords here. Hope this helps someone as I tried finding the dataenvironment answer in the forums but came up short. 1 dead link and another the firewall won't let me see. Thanks for the forums I have found many help ful tips.
Earl

D12Bit
Dec 4th, 2002, 11:54 AM
I post the answer to opening a Pasworded database...

here: http://www.vbforums.com/showthread.php?s=&postid=1259721#post1259721