I got no errors in the code now, but it doesn't seem to work. The only thing that works is when I try to list all the data.
But when I try to narrow the data that is to be listed. I get no good results. Here is my code:
If ComboBox1.SelectedItem = "School" Then
Dim connectionString As String = "Data Source=SENBONZAKURA\SQLEXPRESS;Initial Catalog=testing;User ID=SenbonZakura\Rew; Trusted_Connection=True;"
Dim selectCommand As String
Dim connection As New SqlConnection(connectionString)
selectCommand = "select * from student WHERE (SCHOOL='" & TextBox1.Text & "')"
Me.dataAdapter = New SqlDataAdapter(selectCommand, connection)
Dim commandBuilder As New SqlCommandBuilder(Me.dataAdapter)
Dim table As New DataTable()
Me.dataAdapter.Fill(table)
Me.BindingSource1.DataSource = table
Dim data As New DataSet()
DataGridView1.DataSource = Me.BindingSource1
END IF
The code above is not the whole thing. I've omitted those that are not relevant. What do I do to make this work?Please help, thanks.