Click to See Complete Forum and Search --> : Data Set Question about SQL Query
tenno
May 30th, 2006, 09:27 AM
ASP.net 2.0 (VB):
While creating a new data set in design mode, I'm using the query builder and trying to write a query within "LIKE" for example:
SELECT * FROM table WHERE field LIKE @'%TextBoxData%'
but this query doesn't work...any clue to make it work? I mean using query builder in design mode...
$.02
May 30th, 2006, 09:40 AM
Remove the @ sign...
SELECT * FROM table WHERE field LIKE '%TextBoxData%'
tenno
May 30th, 2006, 10:02 AM
No, i don't want hard code the textbox value, i want a flexible value
HairyMonkeyMan
May 30th, 2006, 10:10 AM
Who said anything about hardcoding values?
Use the @ symbol to denote a variable..
Maybe this is what you want?SELECT * FROM table WHERE field LIKE %@TextBoxData%
where @TextBoxData is your variable.
tenno
May 30th, 2006, 10:33 AM
Maybe this is what you want?SELECT * FROM table WHERE field LIKE %@TextBoxData%
where @TextBoxData is your variable.
I tried that before, it's don't work either, error in building query
HairyMonkeyMan
May 30th, 2006, 10:39 AM
what DBMS are you using?
tenno
May 30th, 2006, 10:47 AM
SQL server 2005
tenno
June 1st, 2006, 12:53 AM
Ok ladies and gentlement, finally i found the solution, let's learn this elite technic:
SELECT * FROM table WHERE field LIKE '%' + @TextBoxData.Text + '%'
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.