Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public strkoneksi As String
- Public conn As New ADODB.Connection
- Public rsUser As New ADODB.Recordset
- Public Function Koneksi() As Boolean
- 'settingan koneksi
- On Error GoTo er
- 'koneksi string ke mysql konektor
- strkoneksi = "DRIVER={MySQL ODBC 5.1 Driver};SERVER=" & "localhost" & ";DATABASE=" & "latihan" & ";UID=" & "root" & ";PWD=" & "admin" & ";PORT=" & "3306" & ";OPTION=3"
- If conn.State = adStateOpen Then conn.Close
- conn.Open strkoneksi
- conn.CursorLocation = adUseClient
- 'buka tabel database
- rsUser.Open "SELECT nama,Password FROM user", strkoneksi, adOpenKeyset, adLockOptimistic
- If conn.State = adStateOpen Then
- Koneksi = True
- Exit Function
- Else
- Koneksi = False
- Exit Function
- End If
- Exit Function
- er:
- Koneksi = False
- MsgBox "Gagal Loading Database", vbInformation, "Database Error"
- End Function
- '==========================================================
Advertisement
Add Comment
Please, Sign In to add comment