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!

DAO and AC97 passwords

Status
Not open for further replies.

Scoty

Programmer
Oct 25, 2000
278
US
HELP!,
I have been working on this project for 4 months now and I have one more peice of the puzzle to work out. I have a program where I access an AC97 backend and I wish to password protect that back end is there anyway, using DAO, to pass the password back to the database here is what I have:
Code:
Set ldbBrains = OpenDatabase(App.Path & "/mdb/Brain.mdb")
of course I get a runtime 3031 and not a valid password description. So how do I do it. OK geniuses have at it

Thanks
Scoty ::) "Learn from others' mistakes. You could not live long enough to make them all yourself."
-- Hyman George Rickover (1900-86),
 

To change the password it is something like
[tt]
DatabaseObject.NewPassword "oldpassword", "newpassword"
[/tt]
But I don't remember if you have to open up the database first with the old password.

Good Luck

 
To open a password protected db:
Set db = DBEngine.OpenDatabase(App.Path & "/mdb/Brain.mdb"
,False, False, ";pwd=123456")

Add password:

Set db = DBEngine.OpenDatabase(App.Path & "/mdb/Brain.mdb,True,False)

db.NewPassword "","ABC"

Change password:

Set db = DBEngine.OpenDatabase(App.Path & "/mdb/Brain.mdb,True,False";pwd=ABC")

db.NewPassword "ABC","123" [/b][/i][/u][sub]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
CCLINT,
This is pretty close to what I need. But I don't use DBEngine. What is this exactly. Would there be any advantages (other that password of course) to using DBEngine.
Thanks
Scott "Learn from others' mistakes. You could not live long enough to make them all yourself."
-- Hyman George Rickover (1900-86),
 
You said you use DAO...so, you are using the DBEngine:

Set db = Dao.DBEngine.Opendatabase
Set db = Dao_Opendatabase
Set db = Opendatabase
Set db = Dao.Workspaces(0).OpenDatabase
Set db = Dao.DBEngine.Workspaces(0).OpenDatabase

All the same thing here (except the last method where you can use a specific workspace rather than the default)

DBEngine is a default property of DAO.

Correct is (and to prevent any possible conflicts):

Set db = Dao.DBEngine.Opendatabase
Or:
Set db = Set db = Dao.DBEngine.Workspaces(0).OpenDatabase

And, in most all cases;

Set db = Dao_Opendatabase

is sufficient.
[/b][/i][/u][sub]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
I'm Sorry. I should have clarified. I have a vb6 fe and and and a97 be. The above code along with
Code:
Dim ldbBrains as Database
Dim lrsBrains as Recodset
Dim lsBrains as String

lsBrains = "SELECT *" & Chr(13) & _
          "FROM MyTable;" ' my sql string
Set ldbBrains = OpenDatabase(App.Path & "/mdb/Brain.mdb")
Set lrsBrains = ldbBrains.OpenRecorset(ldbBrains)

With lrsBrains ' and so on and so on

is this not DAO?  Am I confused is it ADO I'm not sure

Sorry
Scoty ::-) "Learn from others' mistakes. You could not live long enough to make them all yourself."
-- Hyman George Rickover (1900-86),
 
You are using ADO

what I mostly do to connect to a database is the following.
I create a module with all the parameters to connect to the database
Put the following code in a module

******************************************************
Option Explicit
Public myConn As New ADODB.Connection
Public RS As New ADODB.Recordset
Dim Cmd As New ADODB.Command


Public Sub CloseConn()
RS.Close
myConn.Close
End Sub

Public Sub OpenConn(myDatabase As String, myPath As String, sqlCode As String, strPwd As String)

Dim AccessConnect As String
Dim stQuery As String

AccessConnect = "Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=" & myDatabase & ";" & _
"DefaultDir=" & myPath & ";" & _
"Uid=;Pwd=" & strPwd & ";"
myConn.ConnectionString = AccessConnect
myConn.Open

With Cmd
Set .ActiveConnection = myConn
.CommandType = adCmdText
.CommandText = sqlCode
End With

With RS
.LockType = adLockPessimistic
.CursorType = adOpenKeyset
.Open Cmd
End With

End Sub

********************************************************
you can use the module like this


*********************************************************

Dim lsBrains As String
lsBrains = "SELECT *" & Chr(13) & "FROM MyTable"

OpenConn"Brain.mdb", App.Path & "/mdb/", lsBrains ,YourPass

***********************************************************

This should do the trick

Good luck
 
I guess I have a lot to learn, yet. My code (see responce #5) is ALL that i use to get to my back end databases. So what am I using? Do I need to start a new thread?

Scott ::) "Learn from others' mistakes. You could not live long enough to make them all yourself."
-- Hyman George Rickover (1900-86),
 
I thought I pointed you in the right direction.
If you use the code I posted here before you should be able to connect to your database.
After the connection is made you can drop your own code and do whatever you are doing in your application.



**********************Begin code***********************
Dim lsBrains As String
lsBrains = "SELECT *" & Chr(13) & "FROM MyTable"

OpenConn"Brain.mdb", App.Path & "/mdb/", lsBrains ,YourPass
With lrsBrains ' and so on and so on
'Do your stuff
end with

'Don't forget to close your connection

CloseConn


***********************end code


PS if you are using ADO then you must have the references
* Microsoft ActiveX Data Objects 2.x (x = 1 or 5 or 6 or 7)
* Microsoft ActiveX Data Objects Recordset 2.x
 

>You are using ADO

Imhoteb:

Scoty stated that DAO is being used and now is confused.
This (your statement) may have made more confusion.

If you will notice, the person is using statements like:

>Set ldbBrains = OpenDatabase(App.Path & "/mdb/Brain.mdb")

>Dim ldbBrains as Database

>Set ldbBrains = OpenDatabase(App.Path & "/mdb/Brain.mdb")

>Set lrsBrains = ldbBrains.OpenRecorset(ldbBrains)

should have identified to you that this is DAO, and not ADO.

Also, Imhoteb,

>* Microsoft ActiveX Data Objects 2.x (x = 1 or 5 or 6 or 7)
>* Microsoft ActiveX Data Objects Recordset 2.xto use ADO

you only need a reference to the first mentioned item.
The second reference is ADOR, (and has limited capabilities and therefore has less overhead), and has a different purpose.



[/b][/i][/u][sub]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top