VB Access Data Con with Password
Page 1 of 1
VB Access Data Con with Password
To Connect access database with password protection in vb the following module is:
Public Sub MAKECONNECTION(ByVal cn As ADODB.Connection, rs As ADODB.Recordset, SQLQUERY As String)
'CLOSE THE CONNECTION IF ALREADY OPEN
If cn.State = adStateOpen Then
cn.Close
End If
'OPENS A CONNECTION TO DATA SOURCE(FOR MS ACCESS)
With cn
'.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "D:\database.mdb" & ";Persist Security Info=False;Jet OLEDB:Database Password=debmedia"
.CursorLocation = adUseClient
.Open
End With
'OPENS A RECORDSET
With rs
.CursorLocation = adUseClient
.LockType = adLockOptimistic
.CursorType = adOpenDynamic
.Source = SQLQUERY
.ActiveConnection = cn
.Open
End With
Public Sub MAKECONNECTION(ByVal cn As ADODB.Connection, rs As ADODB.Recordset, SQLQUERY As String)
'CLOSE THE CONNECTION IF ALREADY OPEN
If cn.State = adStateOpen Then
cn.Close
End If
'OPENS A CONNECTION TO DATA SOURCE(FOR MS ACCESS)
With cn
'.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "D:\database.mdb" & ";Persist Security Info=False;Jet OLEDB:Database Password=debmedia"
.CursorLocation = adUseClient
.Open
End With
'OPENS A RECORDSET
With rs
.CursorLocation = adUseClient
.LockType = adLockOptimistic
.CursorType = adOpenDynamic
.Source = SQLQUERY
.ActiveConnection = cn
.Open
End With
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum