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

    conn = New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0.C:\Video Rental System\DvDSystem1.accdb")
    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
        End If
    ElseIf txtUsername.Text <> "" Then
        If txtPassword.Text <> "" Then
            MessageBox.Show("Wrong login, please try again ...", "Login Denied", MessageBoxButtons.OK)
            MessageBox.Show("Please enter password", "Login Error", MessageBoxButtons.OK)
        End If
        MessageBox.Show("Please enter user id", "Login Error", MessageBoxButtons.OK)
    End If
    'Clear password field after login
Catch ex As Exception
    MessageBox.Show("Please exit system and login again.", "Login Error", MessageBoxButtons.OK)
End Try


End Sub

Recommended Answers

All 5 Replies

Your connection string is incorrect.

Should be:
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Video Rental System\DvDSystem1.accdb"

Also add the following:

Catch ex As OleDB.OleDbException

Access Connection String

still getting the following error:
MessageBox.Show("Please exit system and login again.", "Login Error", MessageBoxButtons.OK)

As I mentioned in your other post, use the exception object to determine the ACTUAL reason for the error (located by looking at ex.Message).
It will, normally quite clearly, point you to the exact problem.
Alternatively, step through your code in debug mode and see which line of code causes the crash.

now im getting the error "no value given for one or more parameters"

any suggestion on which steps to take from here?

got the answer...what i had to do was put [] brackets in fields with spaces.

thanks guys for all your efforts..really appreciate it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.