Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OpenDatabase method. Help!

Status
Not open for further replies.

seaport

MIS
Jan 5, 2000
923
US
I am using Access 97. I try to use OpenDatabase method to open a database protected by the database password. The code is:<br><br>Dim db As Database<br>Set db = OpenDatabase(&quot;c:\test\backend.mdb&quot;, , , &quot;ODBC; pwd=a&quot;)<br><br>However, I always get the error message telling me that the password is invalid. I am pretty sure that the password I typed - &quot;a&quot; is correct.<br><br>I do not think this is a complicated problem. But I just can not get through it. What mistake do I make?<br><br>Any help is appreciated. Thanks in advance.<br><br>Seaport
 
don't you need a User ID and a password<br>ODBC; DATABASE=database; UID=user; PWD=password; DSN= datasourcename;<br><br>Make sure you can open the database by double clicking on it&nbsp;&nbsp;in Explorer and when it asks for a password the key in &quot;a&quot;.<br><br>And can you open it with this<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim MyDB As Database, MyTable As Recordset<br>&nbsp;&nbsp;&nbsp;&nbsp;Set MyDB = OpenDatabase(&quot;c:\test\backend.mdb&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;Set MyTable = MyDB.OpenRecordset(&quot;yourtable&quot;)<br><br>without the password <br>If it requires on it will prompt you.<br> <p>DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.
 
DougP<br><br>Thanks for your response. But I still can not get the problem solved.<br><br>I use only database-level security and there is no user level security. What I am not clear is what password (the database password or the user password) the OpenDatabase method needs. For the database I am working on, there is only one database password - &quot;a&quot;. Since there is no user level security, I always log on as &quot;Admin&quot; and there is no password for &quot;Admin.&quot;<br><br>I did open the backend database with password &quot;a&quot; from Windows Exploer.<br><br>I also tried opening the database without password like the following<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim MyDB As Database, MyTable As Recordset<br>&nbsp;&nbsp;&nbsp;&nbsp;Set MyDB = OpenDatabase(&quot;c:\test\backend.mdb&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;Set MyTable = MyDB.OpenRecordset(&quot;yourtable&quot;)<br>And I got the same error message telling that password is invalid. The run-time error number is 3031.<br><br><br><br>
 
I've had this exact same problem, trying to build up the &quot;Connect&quot; variable with a &quot;;PWD=mypassword&quot;.. Seems straightforward, but it just will not work. Can anybody post a snippet of code that opens a dbase with database-level security? I could change to ADO but it seems a big deal for such a small problem.

regards,

WSA [sig][/sig]
 
i put in False fields (Boolean values) for your missing options and it worked
so
Set db = OpenDatabase(&quot;c:\test\backend.mdb&quot;, false, false, &quot;ODBC; pwd=a&quot;)
try it

 
I follow the enhan method,
dim gws as workspace
dim gdb as database
Set gws = CreateWorkspace(&quot;&quot;, &quot;admin&quot;, &quot;&quot;)
Set gdb = gws.OpenDatabase(&quot;c:\test\backend.mdb&quot;, False, False, &quot;ODBC;pwd=a&quot;)

but I set my mdb file password in access with open file exclusive.

so when I open my program it give me run time error &quot;3151&quot;-ODBC connection to 'c:\test\backend.mdb' failed

Please help me on it

Thanks

Regards,
BROS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top