I use Microsoft Activex Data Object 2.8 Library
here is my code!
module...
Public conConnection As New ADODB.Connection
Public rsRecord As New ADODB.Recordset
Public Sub DBConnection()
conConnection.Open
Set conConnection = New ADODB.Connection
conConnection.CursorLocation = adUseClient
conConnection.Open "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = " & App.Path & "\database\guidance.mdb"
End Sub
Login Button
f Text1.Text = "" Then
MsgBox "Please Enter Account!", vbCritical, "Error"
Text1.Text = ""
Text2.Text = ""
Exit Sub
End If
DBConnection
Set rsRecord = New ADODB.Recordset
rsRecord.Open "Select * from User where Username = '" & Text1.Text & "' And Password = '" & Text2.Text & "'", conConnection, adOpenForwardOnly, adLockOptimistic
'
If Text1.Text = " & Username & " And Text2.Text = " & Password & " Then
MsgBox "Login Succeeded!", vbInformation + vbOKOnly, "Successfully Login!"
'Shell "Main", vbNormalFocus
Else
MsgBox "Username:" & Text1.Text & " and Password did not match any records from DataBase!", vbCritical, "Error"
Text1.Text = ""
Text2.Text = ""
End If
'close the recordset
rsRecord.Close: Set rsRecord = Nothing
'close the connection
conConnection.Close: Set conConnection = Nothing
End Sub
tnx in advance!
- 2 views