-3

I created a table in SQL server and I linked it to my UWP app, using the method from Microsoft website : https://learn.microsoft.com/en-us/windows/uwp/data-access/sql-server-databases Now my question is, how will I be able to implement a search function? for example the user types The name it should bring the results back. I intend to use a search box or a text box.

Dozy
  • 11
  • 5

1 Answers1

0

As a starting point, take a look at https://www.w3schools.com/sql/sql_like.asp

You can build your statement around this.

SELECT * FROM Products WHERE ProductDescription LIKE '%textboxinput';

This example finds any values that end with "textboxinput". You can play around with the wildcards mentioned in the link to get the desired behaviour.

Going by the code in your link, you can then go and just clone your GetProducts() Method, rename and edit it to fulfill your needs. In particular, the constant GetProductsQuery needs to be edited with the appropriate sql statement mentioned above.

If you would for example search for 'ng' as your input, only the datasets with the ids 2 4 would be selected.

danielP
  • 23
  • 1
  • 2
  • 6
  • Will this statement come under the event handler? and us there a way to display the data the user has typed into the textbox? – Dozy Sep 18 '18 at 14:35
  • look at the accepted answer at https://stackoverflow.com/questions/21709305/how-to-directly-execute-sql-query-in-c-have-example-batch-file to find out how to directly execute an sql statement. – danielP Sep 18 '18 at 14:38