|
-
Feb 4th, 2006, 09:22 AM
#1
Thread Starter
Lively Member
Opening a database with password on VB (DAO)
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")
-
Feb 4th, 2006, 09:27 AM
#2
Re: Opening a database with password on VB (DAO)
You need to provide more parameters to the OpenDatabase function (specifically the Connect parameter), eg:
VB Code:
set db = DBEngine.OpenDatabase(App.Path & "\database.mdb", , ,"ODBC; pwd=mypassword")
(I'm afraid I have no idea if the connect string here is correct!)
-
Feb 4th, 2006, 09:30 AM
#3
Thread Starter
Lively Member
Re: Opening a database with password on VB (DAO)
yeah i couldnt make it work
-
Feb 4th, 2006, 09:37 AM
#4
Re: Opening a database with password on VB (DAO)
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
-
Feb 4th, 2006, 09:43 AM
#5
Thread Starter
Lively Member
Re: Opening a database with password on VB (DAO)
what would be the next best thing for protecting your access database without disrupting your vb codes? hide it?
-
Feb 4th, 2006, 09:50 AM
#6
Re: Opening a database with password on VB (DAO)
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.
-
Feb 4th, 2006, 11:54 AM
#7
Re: Opening a database with password on VB (DAO)
Try this
VB Code:
DBEngine.DefaultUser = "username"
DBEngine.DefaultPassword = "MyPassword"
DoEvents
'Open the database
Set gdbRWTS = Workspaces(0).OpenDatabase(pathtodatabase)
-
Feb 4th, 2006, 12:07 PM
#8
Re: Opening a database with password on VB (DAO)
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.
Danny
Never Think Impossible
If you find my answer helpful then please add to my reputation
-
Feb 5th, 2006, 11:38 PM
#9
Re: Opening a database with password on VB (DAO)
 Originally Posted by si_the_geek
You need to provide more parameters to the OpenDatabase function (specifically the Connect parameter), eg:
VB Code:
set db = DBEngine.OpenDatabase(App.Path & "\database.mdb", , ,"[B]ODBC; [/B] pwd=mypassword")
(I'm afraid I have no idea if the connect string here is correct!)
The bold part doesn't seem to be needed.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|