ok i gave a password for my access database, now when i open it in VB, it says invalid password, what could be my code to open the password?
VB Code:
set db = DBEngine.OpenDatabase(App.Path & "\database.mdb") set rs = db.openrecordset("table")
Printable View
ok i gave a password for my access database, now when i open it in VB, it says invalid password, what could be my code to open the password?
VB Code:
set db = DBEngine.OpenDatabase(App.Path & "\database.mdb") set rs = db.openrecordset("table")
You need to provide more parameters to the OpenDatabase function (specifically the Connect parameter), eg:
(I'm afraid I have no idea if the connect string here is correct!)VB Code:
set db = DBEngine.OpenDatabase(App.Path & "\database.mdb", , ,"ODBC; pwd=mypassword")
yeah i couldnt make it work :(
I'm sure there are several working examples on the forums, a search should find them.
Oh and by the way, in case it helps the default username for Access databases with passwords is Admin
what would be the next best thing for protecting your access database without disrupting your vb codes? hide it?
Hiding it would do nothing at all in many cases, as many people have 'view hidden files' turned on.
If you have even the slightest need for keeping the data secure, get the password working. "disrupting" your code should not be an issue for you.
There are working examples on the forums of how to make this particular code work.
Try this
VB Code:
DBEngine.DefaultUser = "username" DBEngine.DefaultPassword = "MyPassword" DoEvents 'Open the database Set gdbRWTS = Workspaces(0).OpenDatabase(pathtodatabase)
There are numerous methods you could use with Access to secure the data.. A lot of this will depend on the version that you are using..
You can prevent access to the database window and disable full menus and special keys.
You could save the database as an mde (but make sure you have a back-end front-end split otherwise you will be unable to develop) and more importantly make sure you have a back-up to revert to.
It does also depend on what you are wanting to hide and from who. If it is the code then switching to an MDE will prevent access. If it is the table data itself then you have far less option.
The bold part doesn't seem to be needed.Quote:
Originally Posted by si_the_geek