0% found this document useful (0 votes)
47 views2 pages

Nama: Azhariansyah Siregar Nim: 152406021 Group: KA 2 Tugas: 01

This document contains code for a login form in Visual Basic that connects to an Access database. The form contains text boxes for a username and password. The check() subroutine opens a connection to the database, executes a SQL query to validate the login credentials, and displays a message if login succeeds or fails by clearing the text boxes.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views2 pages

Nama: Azhariansyah Siregar Nim: 152406021 Group: KA 2 Tugas: 01

This document contains code for a login form in Visual Basic that connects to an Access database. The form contains text boxes for a username and password. The check() subroutine opens a connection to the database, executes a SQL query to validate the login credentials, and displays a message if login succeeds or fails by clearing the text boxes.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Nama : Azhariansyah Siregar

Nim : 152406021
Group : KA 2
Tugas : 01

Sourcode Login dengan Database di Visual Basic Studio dengan Acces

Public Class Form1

Sub clear()
TxtUsername.Clear()
TxtPassword.Clear()
End Sub

Sub check()
Dim sql As String
sql = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=databaseku.accdb;"
Dim con As New OleDb.OleDbConnection(sql)
con.Open()
Dim cmd As OleDb.OleDbCommand = New OleDb.OleDbCommand("Select * from login
where username ='" & TxtUsername.Text & "‘ and password='" & TxtPassword.Text & "‘",
con)
Dim sdr As OleDb.OleDbDataReader = cmd.ExecuteReader()

If (sdr.Read() = True) Then

MsgBox("Login Berhasil !", MsgBoxStyle.Information, "")


Call clear()
Else

MsgBox("Maaf Username dan Password Tidak Terdaftar !",


MsgBoxStyle.Critical, "")
clear()
: Exit Sub
End If

End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles
MyBase.Load
clear()

End Sub

Private Sub BtnClear_Click(ByVal sender As Object, ByVal e As EventArgs) Handles


BtnClear.Click
clear()
End Sub

Private Sub BtnLogin_Click(ByVal sender As Object, ByVal e As EventArgs) Handles


BtnLogin.Click
If TxtUsername.Text = "" Or TxtPassword.Text = "" Then
: Exit Sub
End If
check()
End Sub
End Class
Print Screen Login

You might also like