Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Function OpenMyRecordset(rs As ADODB.Recordset, strSQL As String, Optional rrCursor As rrCursorType, Optional rrLock As rrLockType, Optional bolClientSide As Boolean) As ADODB.Recordset
- On Error GoTo ErrorHandler
- If con.State = adStateClosed Then
- con.ConnectionString = connection_str
- 'con.ConnectionString = "DRIVER={MySQL ODBC 5.3 Unicode Driver};" _
- & "SERVER=server_ip;" _
- & " DATABASE=db_name;" _
- & "UID=user;PWD=password;" _
- & "sslca=c:\server-ca.pem;" _
- & "sslcert=c:\client-cert.pem;" _
- & "sslkey=c:\client-key.pem;" _
- & "OPTION=3;"
- ' & "sslverify=1;" _
- con.Open
- End If
- Set rs = New ADODB.Recordset
- With rs
- .ActiveConnection = con
- If bolClientSide Then
- .CursorLocation = adUseClient
- Else
- .CursorLocation = adUseServer
- End If
- .CursorType = IIf((rrCursor = 0), adOpenStatic, rrCursor)
- .LockType = IIf((rrLock = 0), adLockReadOnly, rrLock)
- .Open strSQL
- If .EOF And .BOF Then
- NoRecords = True
- Exit Function
- Else
- NoRecords = False
- End If
- End With
- ExitProcedure:
- Exit Function
- ErrorHandler:
- Debug.Print Err.Description
- If Not rs Is Nothing Then
- If (rs.State And adStateOpen) = adStateOpen Then
- rs.Close
- End If
- Set rs = Nothing
- End If
- If Not con Is Nothing Then
- If (con.State And adStateOpen) = adStateOpen Then
- con.Close
- End If
- Set con = Nothing
- End If
- NoRecords = True
- 'MsgBox Err.Description, vbCritical, "Error:" & Err.number
- GoTo ExitProcedure
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement