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

Setting up Connection to DAO Database 1

Status
Not open for further replies.

Sameal

Programmer
Aug 6, 2001
142
US
I'm using the following code to set my global Database and Workspace variables, however when run it tells me that my password is invalid. However that password IS the correct password. Does anyone see what I'm doing wrong here?

I set the database password through the plain single password lock. There is no user-level security in place.

Public Sub SetupDatabase()
On Error GoTo Err_SetupDatabase

Dim sDbName As String

sDbName = "C:\Windows\Desktop\MLV30D~1.MDB"

'Define global Workspace and Database objects to work
'with MachineLink v3.0 Data.mdb
Set ws = DBEngine.Workspaces(0)
Set db = ws.OpenDatabase(sDbName, False, False, "MSAccess;PWD=Timeless")

Exit_SetupDatabase:

Exit Sub

Err_SetupDatabase:

LogError "SetupDatabase()"

End Sub
 
Sameal,
I could be wrong here (Not the first time) but I think the "Set db" line should look like this:

Set db = ws.OpenDatabase(sDbName, False, False, "MSAccess";PWD:="Timeless")
 
Just in case anyone else has this problem I found the fix to my specific problem though I'm not sure why the original form didn't work. I found that the following does work:

Set db = ws.OpenDatabase(sDbName, False,
False, ";pwd=Timeless")

I guess the 'MSAccess' part of the Connect string was throwing it off. I am guessing that if you are using DAO and are connecting to a Jet database that you do not have to specify the type of ODBC to be connected to.
 
Thanks. I can use AccessDB by DAO.

But I must use 2 .OpenDatabase() statements to link Access or other ODBC driver.

Did anyone know how to use one statement open different databases, like Access2000 and SQL Server2000?

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top