1

i have a table adapter called Tabone and i want to create a query a column where i can retrieve values that are like or contains some character or prefix from the query string .

for example : if i write in a textbox 20 it retrieves all records which contains 20 whether in the beginning or middle or end and each time i add more character it filters more records.

i thought of using textbox_textchanged event

my sql query was :
select [ID] [Name] [description] from [Tabone] where [Name] like ?

but it does not do the job

  • And I suggest that you fetch all the data to a data table.Then under the text changed event, you can do the filter from the data table. – preciousbetine Feb 02 '19 at 17:55
  • Let me straighten out a bit of the semantics. The table in your database is called Tabone; your TableAdapter name is TaboneTableAdapter. I am not familiar with TableAdapters but you can pull a DataTable out of one with the `.GetData` method. Then you can use the `.Select(string)` method on the resulting DataTable to get the rows your are interested in. No need to hit the database again. – Mary Feb 02 '19 at 18:46
  • @Mary i'm displaying the result in a datagridview with a bindingsource. – Christy_mall95 Feb 03 '19 at 06:59
  • https://stackoverflow.com/q/251276/5045688 – Alexander Petrov Feb 03 '19 at 13:59
  • 1
    Try this `like '%" & textbox1.Text & "%'"` – preciousbetine Feb 04 '19 at 13:52

0 Answers0