Cara buat Login Case Sensitive Vb.Net
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click, btnExit.Click
If txtNm_user.Text = "" Or txtpswd.Text = "" Then
MsgBox("Lengkapi data login anda")
If txtNm_user.Text = "" Then txtNm_user.Focus()
If txtpswd.Text = "" Then txtpswd.Focus()
Exit Sub
Else
Dim sqlOpen As String = "select * from tbuser where nama_user='" & txtNm_user.Text & "' and psw='" & txtpswd.Text & "'"
Try
cekkoneksi()
With sqlCommand
.CommandText = sqlOpen
.Connection = skoneksi
End With
DR = sqlCommand.ExecuteReader
DR.Read()
If DR.HasRows Then
Dim nama As String = DR.Item("nama_user")
Dim pwd As String = DR.Item("psw")
If txtNm_user.Text = nama And txtpswd.Text = pwd Then
Me.Visible = False
MDIParent1.Show()
MDIParent1.Panel2.Text = DR.Item("nama_user")
MDIParent1.Panel3.Text = DR.Item("hak_akses")
If MDIParent1.Panel3.Text = "OPERATOR" Or MDIParent1.Panel3.Text = "operator" Or MDIParent1.Panel3.Text = "user" Then
MDIParent1.InputUserToolStripMenuItem.Enabled = False
Else
MDIParent1.InputUserToolStripMenuItem.Enabled = True
End If
Else
End IfIf txtNm_user.Text = "" Or txtpswd.Text = "" Then
MsgBox("Lengkapi data login anda")
If txtNm_user.Text = "" Then txtNm_user.Focus()
If txtpswd.Text = "" Then txtpswd.Focus()
Exit Sub
Else
Dim sqlOpen As String = "select * from tbuser where nama_user='" & txtNm_user.Text & "' and psw='" & txtpswd.Text & "'"
Try
cekkoneksi()
With sqlCommand
.CommandText = sqlOpen
.Connection = skoneksi
End With
DR = sqlCommand.ExecuteReader
DR.Read()
If DR.HasRows Then
Dim nama As String = DR.Item("nama_user")
Dim pwd As String = DR.Item("psw")
If txtNm_user.Text = nama And txtpswd.Text = pwd Then
Me.Visible = False
MDIParent1.Show()
MDIParent1.Panel2.Text = DR.Item("nama_user")
MDIParent1.Panel3.Text = DR.Item("hak_akses")
If MDIParent1.Panel3.Text = "OPERATOR" Or MDIParent1.Panel3.Text = "operator" Or MDIParent1.Panel3.Text = "user" Then
MDIParent1.InputUserToolStripMenuItem.Enabled = False
Else
MDIParent1.InputUserToolStripMenuItem.Enabled = True
End If
Else
Else
MsgBox("Pasword anda salah")
txtNm_user.Clear()
txtpswd.Clear()
txtNm_user.Focus()
txtpswd.Enabled = False
End If
Catch ex As Exception
End Try
sqlCommand.Dispose()
skoneksi.Close()
End If
End Sub
Private Sub FLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
txtNm_user.Focus()
txtpswd.Enabled = False
End Sub
Private Sub txtNm_user_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtNm_user.KeyPress
If e.KeyChar = Chr(13) Then
txtpswd.Enabled = True
txtpswd.Focus()
End If
End Sub
Private Sub txtpswd_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtpswd.KeyPress
If e.KeyChar = Chr(13) Then
btnLogin.Focus()
End If
End Sub

EmoticonEmoticon