Friday, February 24, 2012

Error in building SQL query within "LIKE" statement for TableAdapter in Design Section

ASP.net 2.0 (VB), SQL Server 2005:

While creating a new TableAdapter in design section, I'm using the query builder and trying to write a query within "LIKE" statement as below -

Example1: SELECT * FROM table WHERE field LIKE @.'%TextBoxData%'
Example2: SELECT * FROM table WHERE field LIKE'%@.TextBoxData%'

but these query doesn't work...error in building query...any clue to make it work? If I remove "@." sure the query will work with normal but '%TextBoxData%' will become a hardcoding value...this is not I want...I want make the TextBoxData become a flexible value depend on the data what I enter in my text box like 'abc,123' not like 'TextBoxData'...

I know normally it supposed to be like:

"SELECT * FROM table WHERE field LIKE'%" & TextBoxData.Text & "%'"


It can work when inCode Section, but not at this time...because now i'm trying to made it with "Query Builder" for TableAdapter " inDesign Section...hmm did you get what I mean? Sorry for my bad english

Thanks in advance

Hi, you can use such query which should beinterpreted correctly as T-SQL command:

SELECT * FROM table WHERE field LIKE '%'+TextBoxData+'%'

|||

Nice work, how thanksIori_Jay, you are the manBig Smile

|||It Should be'%'+@.TextBoxData+'%'

No comments:

Post a Comment