I am trying to use listboxes to categorize data and I am trying to use SQL to do so.
that link is what the form looks like know and what i'm trying to do - to use the listboxes to view the records by student year.
For the first list box here is the code for the first listbox to sort the data by year:
Imports System.Data.OleDb
Public Class viewStudent
Private Sub viewStudent_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'ProjDataSet1.Details' table. You can move, or remove it, as needed.
Me.DetailsTableAdapter1.Fill(Me.ProjDataSet1.Details)
' OleDbDataAdapter1.Fill(DataSet11)
End Sub
Private Sub lstYear_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstYear.SelectedIndexChanged
Dim Year, SQLString As String
Dim dtDetails As New DataTable()
Dim dbDataAdapter As OleDbDataAdapter
Dim ConnectString As String = "Provider = Microsoft.Jet.OLEDB.4.0;" & _
"Data Source = proj.accdb"
Year = lstYear.Text
SQLString = "SELECT * FROM Details WHERE Year = " & "'" _
& Year & "'" & ""
dbDataAdapter = New OleDbDataAdapter(SQLString, ConnectString)
dbDataAdapter.Fill(dtDetails)
grdRecords.DataSource = dtDetails
End Sub
End Class
But i get the error in the link below:
Can someone help to fix this? Thank you!