Hi everyone,
I'm having a little difficultywith parameterized values for a database. Below is my code:
[queries is an arry list of two strings: "flower" and "corner"]
SelectCmd = SELECT * FROM tblProducts WHERE(product_keywords LIKE'%@dotnet.itags.org.FLOWER%') OR (product_keywords LIKE'%@dotnet.itags.org.CORNER%')cmd =new OleDbCommand(SelectCmd);string paramValue;foreach (string xin queries) { paramValue ="@dotnet.itags.org." + x.ToUpper(); cmd.Parameters.Add(paramValue, OleDbType.VarChar); cmd.Parameters[paramValue].Value = x; }
When I take off the parameters and the @dotnet.itags.org., I get 71 records returned but with the parameters no records are returned nor any error, furthermore I can't debug the statement.
Any input would be appreciated.
Thanks.
Eitan
It's the "...Like'%@.FLOWER%'... stuff that's the issue...
(untested...but try)... Like '%' + @.FLOWER + '%'.....
When I have done this I typically stick the % in the Value
So the Query would be
WHERE (Product_Keywords LIKE @.FLOWER )
And then the cmd.Parameters[paramValue].Value = "%" + x + "%";
0 comments:
Post a Comment