I’m trying to complete an assignment where we have to interact with an Access database via a BindingNavigator in Visual Studio with VB. The one table is called Grades, where the grades of students are stored, and we must navigate it with the Navigator. We have to be able to add, delete, save and go through the records. But I can’t get it right, I just keep getting an error like this, no matter what:
I’m not sure what else I can do? I’ve recreated the BindingSource, and Navigator multiple times but to no effect. I’ve managed to get the first record (which I had to hard-code in Access) to display in the text boxes of the GUI thanks to the DataBindings property (at the bottom of this post). But the same error pops up if I press the previous-item button to get back to it. No matter what I do with the Navigator it is always the same error.
The Display Grades button does what it’s supposed to (tested it with hard-coded records from Access). So it’s just the Navigator that’s being finicky.
GUI:
I don’t spot anything wrong with my code either.
Public Class frmGrades
Private Sub frmGrades_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'StudentsDataSet.Students' table. You can move, or remove it, as needed.
Me.StudentsTableAdapter.Fill(Me.StudentsDataSet.Students)
'TODO: This line of code loads data into the 'GradesDataSet.Grades' table. You can move, or remove it, as needed.
Me.GradesTableAdapter.Fill(Me.GradesDataSet.Grades)
End Sub
Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles btnDisplay.Click
Dim query = From studentGrade In GradesDataSet.Grades
Join student In StudentsDataSet.Students
On studentGrade.studentID Equals student.studentID
Let semesterAvg = ((studentGrade.firstExam + studentGrade.secondExam + 2 * studentGrade.finalExam) / 4).ToString("N2")
Let studentName = student.firstName & " " & student.lastName
Select studentName, semesterAvg
Order By semesterAvg
dgvDisplay.DataSource = query.ToList
End Sub
Private Sub btnUpdate_Click(sender As Object, e As EventArgs) Handles btnUpdate.Click
bsGrades.EndEdit()
GradesTableAdapter.Update(Me.GradesDataSet.Grades)
End Sub
End Class
Any help would be appreciated.