Visual Basic to SQL connection problem
Hi everyone,
I am working on a Visual Basic project which is to be accessed by the end of the semester. I am supposed to connect to the SQL database, this is the final phase of the project but it is giving me a headache!
My connection code to the SQL database worked well yesterday, i woke up this morning and did a little bit of connection modification, which seemed right to me according to the tutorials i had. It is kind of i messed up because i can’t successfully connect to the SQL database.
The error in the SQL code line reads:
"Operator '&' is not defined for string "SELECT * FROM Clients WHERE Spec" and type 'DataRowView'."
I really don’t understand where i messed up because this is in its own sub. This specific buttons function is to check if an item selected in the check box exists in the database and then display the items.
Here is the code section,
Private Sub cmdShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdShow.Click
Dim strSQL As String
Dim dt As New DataTable
Dim connStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:Access2003Blank.mdb"
strSQL = "SELECT * FROM Clients WHERE Species = ' " & lstSpecies.SelectedItem & " ' " 'gets all clients that are of the right selected species type ERROR LINE
Dim dataAdapter As New _
OleDb.OleDbDataAdapter(strSQL, connStr)
dataAdapter.Fill(dt)
dataAdapter.Dispose()
DataGridDisplay.DataSource = dt
Can somebody help me out, Please?