1.buatlah sebuah table pada Ms.Acces
2. kemudian isi table tersebut
setelah kita selesai membuat table pada database, kita beranjak ke visual studio. Buatlah sebuah form baru pada visual studio, lalu masukan komponen-komponen sebagai berikut :
2 buah label
2 buah textbox
2 buah button
atur seperti dibawah ini :
atur properties texttbox 1 dan textbox 2 menjadi Webdings dan isi passwordcharnya menjadi “=” (tanpa tanda kutip) untuk menghasilkan password char bulet.
waktunya coding …..
module koneksi
Imports System.Data.OleDb
Module Module1
Public str As String
Public conn As OleDbConnection
Public cmd As OleDbCommand
Public dr As OleDbDataReader
Sub koneksi()
str = “Provider=Microsoft.ACE.OLEDB.12.0;Data Source=DB.accdb”
conn = New OleDbConnection(str)
If conn.State = ConnectionState.Closed Then
conn.Open()
Else
MsgBox(“Koneksi gagal”)
End If
End Sub
End Module
Form Login
Imports System.Data.OleDb
Public Class Form2
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
koneksi()
str = “select * from tbl_user where user_name='” & TextBox1.Text & “‘ and password='” & TextBox2.Text & “‘”
cmd = New OleDbCommand(str, conn)
dr = cmd.ExecuteReader
If dr.Read Then
MsgBox(“Login berhasil”)
Me.Close()
Else
MsgBox(“Gagal”)
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
End Class
Coba lihat hasil nya gan, gimana???
x