sql server - How to seach in C# sql database by LIKE -


i have table , want search in table.

select tbphonebook.* tbphonebook     fname @fanem 

in tbphonebooktableadaptor, , use :

private void search_click(object sender, eventargs e) {      tbphonebooktableadapter.search(this.test4dataset.tbphonebook, textbox1.text); } 

and works fine, when searches word, words contain search expression shown.

for example there these names in database:

ali , alireza , soheil , soheilyou , ....  

in current search if user searches ali program show him ali while alireza contains ali search criteria!

in php use :

select * tbphonebook     fname "%$fanem%" 

but don't know syntax in c#

security concerns aside, use concatenated string query like:

"select tbphonebook.* tbphonebook fname '%"+textbox1.text+"%'" 

an example more secure way avoid sql injections can find here: sql parameters


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -