Friday, 23 August 2013

Implementing search functionality in a database application

Implementing search functionality in a database application

I am creating a database application in vb.net where I need to implement a
search functionality that should search the whole database and return the
user with a list of records found in the databse that contains the search
string in a DataGridView control.
I used one combobox with name: "colNames" and a textbox where we enter the
search the search string with the name "colValues".
Here is the code I used on the click of search the button:



Dim ds As New DataSet
Dim query As String = "select * from customer where " +
colNames.SelectedValue.ToString + " LIKE " + "'%" + colValues.Text + "%'"
CustomerTableAdapter.Connection.Open()
Dim adp As New SqlDataAdapter(query,
CustomerTableAdapter.Connection.ConnectionString)
adp.Fill(ds, "customer")
CustomerTableAdapter.Connection.Close()
filteredRecords.DataSource = ds
filteredRecords.DataMember = "customer"



The code above throws an exception on line 6 (adp.Fill(ds, "customer")):
"The multi-part identifier "System.Data.DataRowView" could not be bound".
Please help me out debugging it or suggest a new code so that I can
implement the search functionality.

No comments:

Post a Comment