Sabtu, 28 Januari 2012

'LOGIN VB DARI DB '

CEEEEKIDOOT...!!!!!

di microsoft access 2003/2007  buat 1 tabel berinama 'tbl_user'
buat username=' '
buat password = ' '
lalu save 

kemudian buat module di vb :
scriptnya : 
Public Conn As New ADODB.Connection
Public Rs As New ADODB.Recordset
Public StrConnect As String
Public StrSQL As String
Public Sub konek()
StrConnect = "Provider=Microsoft.Jet.OleDB.4.0;Data Source=" + App.Path + "\(nama database yang dibuat).mdb"
If Conn.State = adStateOpen Then
Conn.Close
Set Conn = New ADODB.Connection
Conn.Open StrConnect
Else
Conn.Open StrConnect
End If
End Sub


scriptnya :
buat 2 label
buat 2 textbox
buat 2 commamnd button
beri nama masing masing 

Private Sub cmdlogin_Click()
Call konek
sql = "SELECT * FROM tbl_user WHERE username='" & txtUser.Text & "' and password='" & txtPass.Text & "' and status = '1' "
Set Rs = Conn.Execute(sql)
txtUser.SetFocus
If Not Rs.EOF Then

Unload Me
Form2.Show



Else
MsgBox "Maaf Username dan Password Tidak Sesuai!", vbCritical

End If
End Sub







Tidak ada komentar:

Posting Komentar