Hi I have a problem where I am
designing a
VB 2008 project with Ms Access 2010 as a Database Management program, I have created a login form and it works well but it is not case sensitive :O Here is my code:
Imports System.Data
Imports System.Data.OleDb
Public Class LogIn
Public accConnection As New OleDbConnection
Dim strConnectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;
Data Source = C:\Users\Jack\Documents\College
Work\Computing\A2\Coursework\Computer Work\Database\HFDB.accdb;Persist
Security Info=False;"
Private Sub Login_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim strConnectionString As String =
"Provider=Microsoft.ACE.OLEDB.12.0; Data Source =
C:\Users\Jack\Documents\College Work\Computing\A2\Coursework\Computer
Work\Database\HFDB.accdb;Persist Security Info=False;"
accConnection = New OleDbConnection(strConnectionString)
Try
accConnection.Open()
Catch oleDbExceptionErr As OleDbException
MessageBox.Show(oleDbExceptionErr.Message, "Access Error1")
Catch InvalidOperationExceptionErr As InvalidOperationException
MessageBox.Show(InvalidOperationExceptionErr.Messa ge, "Access
Error2")
End Try
If accConnection.State <> ConnectionState.Open Then
MessageBox.Show("Database Connection Failed!")
Exit Sub
End If
End Sub
Private Sub cmdLogin_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdLogin.Click
Dim cmdString1 As String = "SELECT Login_Username, Login_Password "
& "FROM Login "
Dim cmdString2 As String = "WHERE (Login_Username = @Username) AND
(Login_Password = " & "@Password) "
Dim cmdString As String = cmdString1 & cmdString2
Dim accCommand As New OleDbCommand
Dim accDataReader As OleDbDataReader
Dim SelForm As New MainPage
accCommand.Connection = accConnection
accCommand.CommandType = CommandType.Text
accCommand.CommandText = cmdString
accCommand.Parameters.Add("@Username", OleDbType.Char).Value =
txtUsername.Text
accCommand.Parameters.Add("@Password", OleDbType.Char).Value =
txtPassword.Text
accDataReader = accCommand.ExecuteReader
If accDataReader.HasRows = True Then
MessageBox.Show("Login Was Successful!")
SelForm.Show()
Me.Hide()
Else
MessageBox.Show("No Matching Username And Password Found")
End If
accDataReader.Dispose()
accDataReader = Nothing
accCommand.Dispose()
accCommand = Nothing
End Sub
Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdCancel.Click
accConnection.Close()
accConnection.Dispose()
accConnection = Nothing
Me.Close()
End Sub
Can anybody help me by letting me know how I can make this case sensitive!
Any help is greatly appreciated :D
Thanks