[AccessD] Connection String syntax

Gustav Brock Gustav at cactus.dk
Sun Nov 19 13:04:35 CST 2006


Hi Robert

Drew posted this in Sep. 2003 which seems close to what you request:

<quote>


Function fDatabaseConnection(CurrCnn As ADODB.Connection, UserName As
String, PassWord As String)
Set CurrCnn = New ADODB.Connection
With CurrCnn
    .Provider = "Microsoft.Jet.OLEDB.4.0"
    .Properties("Jet OLEDB:System database").Value =
"T:\AccessDB\ISReq\Marlow1.mdw"
    .Open "T:\AccessDB\ISReq\ISReqBE.mdb", UserName, PassWord
End With
End Function

To use the function above, here's an example:

Dim cnn as ADODB.Connection
Dim rs as ADODB.Recordset
Dim strSQL as String
fDatabaseConnection cnn,"UserName","Password"
Set rs=new ADODB.recordset
strSQL="Select * From tblData;"
rs.open strSQL,cnn,adOpenKeyset,adLockReadOnly
if rs.EOF=false then rs.MoveFirst
Do until rs.EOF=True
	'Do something
	rs.MoveNext
Loop
rs.Close
Set rs=nothing
cnn.Close
set cnn=Nothing

Just a little sample code.  I know this code uses ADO, which is the default
in A2k, but in A97, DAO is default.  DAO is the native language for Jet
databases, but I find that ADO is FAR more flexible.  I can write code for
connecting to an Access database, and later on, if I change the data source,
I just have to modify the connection routine.

Drew

</quote>

/gustav

>>> robert at servicexp.com 19-11-2006 19:39:15 >>>

What is the correct syntax when opening from within a FE/BE MS Access when
user security has been moved to a difference, non system, .mdw?

This does not seem to do it..

"PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=CurrentProject.Path &
FEDBName;User Id=administrator; Password=adminpassword"

Thanks 

Robert





More information about the AccessD mailing list