Hi guys pls help,
Im trying to connect to access 2007 database in vb.net 2005 woth no luck.....im using a login form with two text boxes and two buttons, Im tring to log into the database using the below connection string....... (i only get the catch message box error)... Plz help ASAP (thnx)
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.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.Set_KeptProfile(keptProfile)
End If
ElseIf 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