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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

database MSAccess password via Visual Basic 1

Status
Not open for further replies.

Periko

Programmer
Feb 24, 2003
134
BE
Hello,

we have a VB application that uses a MSAccess database. We want to put security on the database at the clients side.

we can put the passwd on the access database by opening exclusively. But we cannot go to our hundred customers to do so.

SO, can I do this from within a vb-application ? Opening the database exclusively and adding the password ?

Thx...
Pedro...
 

Yes, but you need to open a connecton (Cnn) to every database

Cnn.Execute "ALTER DATABASE PASSWORD " & ThePassword & " NULL"

 
Thx JerryKlmns,

That's the syntax i suppose, but how do I have to open my cnn ?

For the moment I do the following :

Dim ThePassword As String

Err.Number = 0
Set cnn = OpenDatabase(MyDB, False, False, ";pwd=xxx")

ThePassword = "yyy"
cnn.Execute "ALTER DATABASE PASSWORD " & ThePassword & " NULL"

This gives the following error :

"Syntax in alter table statement"

Any Idea ?
 
This is for non existing password

Cnn.Execute "ALTER DATABASE PASSWORD " & ThePassword & " NULL"

and this when having one already

Cnn.Execute "ALTER DATABASE PASSWORD " & NewPassword & " " & OldPassword

Open your connection as you please [pipe]
 
Shakespeare,

You refered to an article where i should use

cnn.NewPassword "", "xxx"

that seems fine, but the error i get is that this "can't change password on a shared open database".

How in the world do i open my database as exclusive ?

Pedro...
 
By the was, it's DAO i'm using Shakespeare, not ADO.
 
Try playing around with the connection string you use to open the database, for example "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\TestDB\MyDB.mdb;Mode=Share Deny Read|Share Deny Write"
-Max
 
OK, Guys,

I found it myself, thx to you all !

This does it :

Set cnn = OpenDatabase(mydb, dbSecDBExclusive, False, ";pwd=xxx")

Vis.NewPassword "xxx", "yyy"


Thx...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top