Hy guys,
Please assist in advcicing which toolbox connection controls to add in my form. I want to connect to access 2007 using vb.net 2005 and im struggling. I have two textboxes(username and password) and two buttons(submit and cancel). When I click on the submit button it supposed to allow the user to logon to the system, but it dsnt…my connection string is
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Video Rental System\DvDSystem1.accdb
Which is fine(I think). I can’t get the congurations right for thelogin form in desing view (properties window)
.I need urgent assistance pls help
Here is my code below
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
Dim conn As OleDb.OleDbConnection
Dim cmd As OleDb.OleDbCommand
Dim selectQuery As String
Dim dr As OleDb.OleDbDataReader
Dim userProfile As String
Try
conn = New OleDb.OleDbConnection"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Video Rental System\DvDSystem1.accdb")
conn.Open()
selectQuery = "SELECT * FROM USERR WHERE userID = '" & txtUsername.Text & "' AND userPassword = '" & txtPassword.Text & "'"
cmd = New OleDb.OleDbCommand(selectQuery, conn)
dr = cmd.ExecuteReader
'if successfull then log in
If dr.Read Then
'Get user profile
userProfile = dr.GetString(3)
keptProfile = userProfile
If keptProfile = "admin" Then
MainrMenur.Show()
End If
EseIf txtUsername.Text <> "" Then
If txtPassword.Text <> "" Then
MessageBox.Show("Wrong login, please try again ...", "Login Denied", MessageBoxButtons.OK)
Else
MessageBox.Show("Please enter password", "Login Error", MessageBoxButtons.OK)
txtPassword.Focus()
End If
Else
MessageBox.Show("Please enter user id", "Login Error", MessageBoxButtons.OK)
txtUsername.Focus()
End If
'Clear password field after login
txtPassword.Clear()
catch ex As Exception
MessageBox.Show("Please exit system and login again.", "Login Error", MessageBoxButtons.OK)
End Try
'conn.Close()
Me.Close()
End Sub