I am new to vb. I am trying to get a value for a textbox from a database according to the selected item in combobox. but i had this ex.message
Operator '&' in not defined for string "select*from ......" and type 'dtarowview'
Could anyone please tell me what is wrong with the following code?

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim connstrg As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:\Documents and Settings\hedris\My Documents\REGISTER.mdb;"
Dim conn As New OleDbConnection(connstrg)
Dim DA1 As New OleDbDataAdapter("select* FROM CLARUS where product=" & ComboBox1.SelectedItem & "", conn)
Dim ds1 As New DataSet
Dim dt As New DataTable
DA1.Fill(ds1, "clarus")
dt = ds1.Tables("clarus")
TextBox1.Text = dt.Rows.Item(0).Item(0)
Catch ex As Exception
End Try
End Sub

Hi edriso

Be careful of the difference between


I suspect this may work, though it depends of course on the contents of your combobox:

"select * FROM CLARUS where product='" & ComboBox1.SelectedText & "'"

What data type is the element in your database? Maybe you're trying to post a string to an integer? I've had that problem before, and had to pull the data from the combobox, manipulate it, then use it in a db command.

Its a stretch, but only takes a second to look at. Might be worth it.

This question has already been answered. Start a new discussion instead.