Tweak ADO to use a DB password

G

Guest

I have the following function which uses JET to return a disconnected
recordset; this runs great.

I just need to tweak this function to work with a password protected (i.e. a
database password) Access DB file, can someone show me how best to accomplish
this:

Public Function ADOReturnDisconnectedRecordsetJET(argFullNameDB As String,
argSQL As String) As ADODB.Recordset
'RETURNS A DISCONNECTED ADO RECORDSET TO THE CALLING SUBROUTINE OR FUNCTION
Dim cnAccess As ADODB.Connection
Dim rsAccess As ADODB.Recordset
Set cnAccess = New ADODB.Connection
cnAccess.Provider = "Microsoft.Jet.OLEDB.4.0"
cnAccess.ConnectionString = argFullNameDB
cnAccess.CursorLocation = adUseClient
cnAccess.CommandTimeout = 0 'NO TIMEOUT
cnAccess.Open
Set rsAccess = New ADODB.Recordset
rsAccess.MaxRecords = 0 '0 = ALL RECORDS
Set rsAccess = cnAccess.Execute(argSQL)
Set rsAccess.ActiveConnection = Nothing 'SEVER CONNECTION
Set ADOReturnDisconnectedRecordsetJET = rsAccess.Clone(adLockReadOnly)
'RETURN CLONE
If rsAccess.State = adStateOpen Then rsAccess.Close
Set rsAccess = Nothing
cnAccess.Close
Set cnAccess = Nothing
End Function

Thanks much.
 
S

Stefan Hoffmann

hi,
I have the following function which uses JET to return a disconnected
recordset; this runs great.
I just need to tweak this function to work with a password protected (i.e. a
database password) Access DB file, can someone show me how best to accomplish
this:
Connectionstrings.com

or

create a file with the extension .udl on your desktop. Double click it.
Connect to your password protected .mdb.

Open the .udl file with notepad.


mfG
--> stefan <--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top