Hi All,
can anyone please tell me what's wrong in this code
I'm trying to get some data from an access database and show them in a CheckedListBox
The sql quary includes a variable('sport') and it's values is passed by the user
when I run the following code an exception is thrown at the line
adStudentList.Fill(dsStudentList, "Register")
and it says 'no value given for one or more required parameters'
Dim adStudentList As OleDbDataAdapter
Dim dsStudentList As New DataSet
Dim sport As String
sport = cmbSportList.SelectedItem
Try
cnColors.Open()
Catch ex As Exception
MessageBox.Show("Error in connecting")
End Try
adStudentList = New OleDbDataAdapter("SELECT student_no
FROM register WHERE sport_ID =" & sport, cnColors)
adStudentList.Fill(dsStudentList, "Register")
Dim i As Integer
If dsStudentList.Tables("Register").Rows.Count > 0 Then
For i = 0 To dsStudentList.Tables("Register").Rows.Count - 1
clbStudentList.Items.Add(CStr(dsStudentList.Tables("Register").Rows(i).Item("student_no")), False)
Next
End If
thanks