02 April 2011

Form Login VB to Access

Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim SQL, Pesan As String

Private Sub Command2_Click(Index As Integer)
    If Text1.Text = "" Then
        MsgBox "Masukkan Username dengan benar", vbInformation
        Text1.SetFocus
        Exit Sub
    End If
    If Text2.Text = "" Then
        MsgBox "Masukkan Password dengan benar", vbInformation
        Text2.SetFocus
        Exit Sub

    End If
SQL = "select * from username where username='" & Text1 & "'and password='" & Text2 & "'"
Set rs = New ADODB.Recordset
rs.Open SQL, con, adOpenDynamic, adLockOptimistic, adCmdText
If Not rs.EOF Then
Text1.SetFocus
Text2.SetFocus
Else
    Pesan = MsgBox("Silahkan Anda isi dengan benar", vbInformation)
    Text1.SetFocus
    Text2.SetFocus
    Exit Sub
End If
sisgud.Show (modal)
Unload Me
End Sub


Private Sub Command1_Click(Index As Integer)
Pesan = MsgBox("Apakah Anda Ingin Keluar ?", vbYesNo + vbQuestion, "Konfirmasi Keluar")
If Pesan = vbYes Then
     End
  End If
End Sub

Private Sub Form_Load()
Set con = New ADODB.Connection
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\ahroihan\Documents\tes vb\db1.mdb;Persist Security Info=False"
con.CursorLocation = adUseClient
End Sub
Share:

0 komentar:

Post a Comment

Blog Archive