Imports System.Data.SqlClient
Module Module1
Public CONN As SqlConnection
Public DA As SqlDataAdapter
Public DS As DataSet
Public CMD As SqlCommand
Public DR As SqlDataReader
Public Sub Koneksi()
CONN = New SqlConnection("Data Source=DESKTOP-1H3V5JT; Initial Catalog=dbwayan; Integrated Security=True")
CONN.Open()
End Sub
End Module
2. Bagian Form Login :
Imports System.Data.SqlClient
Public Class LoginForm1
Dim Hitung As Integer = 0
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
Call Koneksi()
CMD = New SqlCommand("select * from tbl_pengajaran where Nm_User='" & UsernameTextBox.Text & "' and Password_User='" & PasswordTextBox.Text & "'", CONN)
DR = CMD.ExecuteReader
DR.Read()
If Not DR.HasRows Then
MsgBox("Login gagal")
Hitung = Hitung + 1
If Hitung > 2 Then
End
End If
Exit Sub
Else
If PasswordTextBox.Text <> DR.Item("Password_User") Then
MsgBox("password salah!")
PasswordTextBox.Focus()
Exit Sub
End If
Me.Visible = False
MenuUtama.Show()
MenuUtama.ToolStripStatusLabel1.Text = DR.Item("kd_User")
MenuUtama.ToolStripStatusLabel2.Text = DR.Item("Nm_user")
MenuUtama.ToolStripStatusLabel3.Text = DR.Item("status_User")
MenuUtama.ToolStripStatusLabel4.Text = DR.Item("Password_User")
If MenuUtama.ToolStripStatusLabel3.Text <> "ADMIN" Then
MenuUtama.UserToolStripMenuItem.Visible = False
End If
End If
End Sub
Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
Me.Close()
End Sub
End Class
Vidio Tutorial : https://youtu.be/st8tlnq0gKs
Tidak ada komentar:
Posting Komentar