Question OleDbException was unhandled. No value given for one or more required parameters.

CallumJames

New member
Joined
Dec 13, 2012
Messages
2
Programming Experience
Beginner
Below is my log-in procedure coded in VB 2010 Express. I'm new to programming so this might be an easy solution for somebody.

I've got this procedure in 3 forms, yet only 1 out of the 3 forms work. The code has been copy and pasted from the one form to the other, with the only change being the database that the username and password is being picked up from is "Customer" instead of "Employee". I've checked the table names in my database (Microsoft Access) which is "Employee" and as you can see it is also spelt correctly in the code.

The error message I keep receiving is: OleDbException was unhandled. No value given for one or more required parameters - on the following line of code:

VB.NET:
Private Sub frmEmployeeHomepage_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        Me.EmployeeTableAdapter.Fill(Me.BridgendBingoHouseDataSet.Employee)
    End Sub



Been reading lots of other threads with similar problems yet I still can't see what's wrong. Would really appreciate if anybody has a solution.

Thanks In Advanced!

:)

VB.NET:
Private Sub frmEmployeeHomepage_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        Me.EmployeeTableAdapter.Fill(Me.BridgendBingoHouseDataSet.Employee)
    End Sub
    Private Sub btnSubmit_Click(sender As System.Object, e As System.EventArgs) Handles btnSubmit.Click

        Dim Found As Boolean
        'total number of rows in the table.
        Dim TotalNumberRows As Integer
        'row number, starting at zero.
        Dim Rowcount As Integer
        'username  picked up from current record in database.
        Dim Username As String
        'password picked up from current record in database.
        Dim Password As String

        TotalNumberRows = BridgendBingoHouseDataSet.Employee.Rows.Count()
        EmployeeBindingSource.MoveFirst()

        Rowcount = 0
        Found = False
        Do Until Rowcount = (TotalNumberRows) Or Found = True

            'looping the tables for usernames & passwords.
            Username = BridgendBingoHouseDataSet.Employee.Rows(Rowcount).Item("EmployeeUsername")
            Password = BridgendBingoHouseDataSet.Employee.Rows(Rowcount).Item("EmployeePassword")

            'checking the database if the input username and password is the same.
            If txtCustomerInformationUsername.Text = Username And txtCustomerInformationPassword.Text = Password Then

                MsgBox("Log in was successful")
                frmPlay.Show()
                Me.Close()
                Found = True
            End If
        Loop
        If Found = False Then
            'If the username and password entered does not match the database then display error message
            MsgBox("Invalid Username or Password")
        End If
    End Sub
End Class

(not sure if there was an easier way to do this but I manually coloured the text as it's displayed in VB so it's easier to read)
 
Last edited:
Hi,

You have given no indication at which point you are getting the error described and on the face of what you have coded there does not appear to be any obvious error that would cause you to get this. You will need to be more specific here for us to be able to help you better.

A couple of points to begin with though:-

1) You have the obvious error of a space in your fill command in the load event, being Me.EmployeeTableAdapter.Fill(Me.BridgendBingoHouse DataSet.Employee). You need to remove the space for completeness.

2) Since you have created your Adapter and DataSet in the VS IDE you can access your DataSet in the following, more compact method, being:-

TotalNumberRows = BridgendBingoHouseDataSet.Employee.Rows.Count()
and
Username = BridgendBingoHouseDataSet.Employee.Rows(Rowcount).Item("EmployeeUsername")
Password = BridgendBingoHouseDataSet.Employee.Rows(Rowcount).Item("EmployeePassword")

3) I am not sure what you are trying to achieve with the movement of the BindingSource in your For loop since this has no function in the code you have written other than to move to the next record in the dataset??

4) When posting code, please encase your code in Code Tags on the Advanced button to make reading code easier.

Please post back with more specific information if you are still struggling.

Cheers,

Ian
 
Thank you very much for your quick reply. I've amended all the points you mentioned, yet I've still got the error unfortunately.

This is where the error message appears:

VB.NET:
Private Sub frmEmployeeHomepage_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        Me.EmployeeTableAdapter.Fill(Me.BridgendBingoHouseDataSet.Employee)
    End Sub


Thanks again

Callum
 
Hi Callum,

Firstly, encase the fill statement in the Load event within a Try / Catch block and add MsgBox(ex.Message) in the Catch section. This should then give you a good steer as to where the problem is.

I suspect that this is going to be something to do with your Data Sources connection information in the IDE. To check this out and possibly reconfigure the connection right-click on your DataSet in the Data Sources window and select Configure Data Source with Wizard.

Hope that helps.

Cheers,

Ian
 
Back
Top