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

How to include password in my database? 1

Status
Not open for further replies.

jcrtektip

Technical User
Mar 3, 2004
18
0
0
SG
I have completed a project using access database. I have used the following connecting method.....

Set wsAccess = DBEngine.Workspaces(0)
Set dbAccess = wsAccess.OpenDatabase(App.Path & "\xxx.mdb")
Set rsAccess = dbAccess.OpenRecordset("SELECT * from t1")

I have used these kind of record set through out my project, extensively. Now I want to impose password for my database. How do I change my code?
 
Are you doing this from VB, if so then this should help:

You have to set up a password in access itself, and then you have to create a "workgroup information file" by going to Tools->security->workgroup administrator

YOu then have to specify this "workgroup information file" in your connection string:

I don't know how you will implement it in your code, but mine looks like this:
Code:
Set cn = New Connection
    cn.CursorLocation = adUseClient
    cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\dbase.mdb;Persist Security Info=false;Jet OLEDB:System Database=" & App.Path & "\WorkgroupInfoFileName;Password=WhateverPassword;User ID=WhateverUsername"

*****************************************
May the Code Be With You...[lightsaber]
----------
x50-8 (X Fifty Eigt)
 
Yes If I change the connection method I can use the password. I need not create any group. In the access database I can set password and use that password in the connection method you have specified.

But my problem is I have use the opendatabase type of connection and the record set used extensively in my vb code. If I change the connection method I should also change the recordset method, so I want to know if there is a work around for this?
 
I'm sorry to say that I am not farmiliar with your method of opening DB and creating a recordset...will it really be that much trouble to change your code?

It looks like you opne the DB everytime you cre3ate a recordset?

I just create my conenction and open it, and it then stays open through the life of my APP, and I just open my recordsets based on my connection?

Maybe I am misunderstanding you...?

*****************************************
May the Code Be With You...[lightsaber]
----------
x50-8 (X Fifty Eigt)
 
There are many ways of connecting a database...
I will explain....
method 1
Set wsAccess = DBEngine.Workspaces(0)
Set dbAccess = wsAccess.OpenDatabase(App.Path & "\x.mdb")
set rsaccess = dbaccess.OpenRecordset("select * from t")
'where x.mdb is the database and t is the table

method 2
strConn = "DRIVER={Microsoft Access Driver (*.mdb)};" & "DBQ=c:\X.mdb;pwd=xxx;"
Set conn = New ADODB.Connection
Set adors = New ADODB.Recordset
Set updateuser = New ADODB.Recordset
conn.Open (strConn)
Set adors.ActiveConnection = conn
adors.open "select * from t"

I have done the connection as mentioned in the first method and I am doing the connection only once in my application.
I have many forms which will use recordset as mentioned in my method 1.
In method 2 the recordset is of open recordset type not set recordset type. so if I use a password i have to use the second method connection and have to change all the forms where i use the set recordset to recordset.open type.

So I want to know if I can use the password in my first method itself? is there any way of dowing it without changing the recordset type?
 
ahhhh yes, now I undetstand, but again I will ask you the question again:

>>...will it really be that much trouble to change your code?

I am afraid that I am not farmiliar with your method of connection, thus I cannot be of any help using your code.

Seeing that I am the only one that replied to your question thus far...

>>...will it really be that much trouble to change your code?

You can allways mail microsoft of check on other VB forums for help

:)

*****************************************
May the Code Be With You...[lightsaber]
----------
x50-8 (X Fifty Eigt)
 
That's because jcrtektip is using DAO whilst you are using ADO - so yes, changing from one to the other is a fairly significant change.

However, no need.

You can use the SystemDB, DefaultUsername and DefaultPassword properties of DBEngine to work with a workgroup security file

Alternatively, if you are just using the simple password securing of an Access database (which really isn't very secure at all), then you can open it something like this:

Set dbAccess = wsAccess.OpenDatabase(App.Path & "\xxx.mdb", False, False, ";PWD=<yourpassword>")
 
Excellent strongm

*****************************************
May the Code Be With You...[lightsaber]
----------
x50-8 (X Fifty Eigt)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top