KenQui
Member
- Joined
- May 11, 2022
- Messages
- 12
- Programming Experience
- Beginner
The thing is I'm creating a log in , in ms visual studio 2010 and ms access database using vb.net language.
Also the username is Admin and the password is admin in database.
The problem is that when I login and input username and password like this admin for username and for password is admin , it will login even when the first letter is big letter it will login.
How to fix this.
It just I want what is in the database as well when I log in, that even if I input a big letter or small letter in the first letter of word if that is not the correct one in the database it will not log in.
Here's my code below.
Also the username is Admin and the password is admin in database.
The problem is that when I login and input username and password like this admin for username and for password is admin , it will login even when the first letter is big letter it will login.
How to fix this.
It just I want what is in the database as well when I log in, that even if I input a big letter or small letter in the first letter of word if that is not the correct one in the database it will not log in.
Here's my code below.
VB.NET:
Imports System.Data.OleDb
Imports System.Data
Public Class AdminLogin
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim con As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source = " & Application.StartupPath & "\UALogin.accdb;")
If TextBox1.Text = Nothing Or TextBox2.Text = Nothing Then
MsgBox("Enter Credentials ", MsgBoxStyle.Exclamation)
Else
If con.State = ConnectionState.Closed Then
con.Open()
End If
Dim cmd As OleDbCommand = New OleDbCommand("SELECT count(*) FROM db_admin WHERE Username =? and Password=?", con)
cmd.Parameters.AddWithValue("@1", OleDbType.VarChar).Value = TextBox1.Text
cmd.Parameters.AddWithValue("@2", OleDbType.VarChar).Value = TextBox2.Text
Dim count = Convert.ToInt32(cmd.ExecuteScalar())
If (count > 0) Then
MsgBox("Login succeed", MsgBoxStyle.Information)
AdminMenu.Show()
Else
MsgBox("Account not found check credentials", MsgBoxStyle.Critical)
End If
End If
End Sub
Last edited by a moderator: