0

I am trying to use like in a Cache sql query such as:

select * from person where name like ?. 

I am passing the parameter like below.

CacheParameter param = new CachemParameter("NAME", CacheDBType.NVarChar);
param.Value = tbxName.Text.ToUpper();
command.parameters.Add(param);

Then I execute the reader.

The results is nothing. I know in MSSQL I use name like 'Lawson%'. How do I do this in a Cache query?

TIA Mike

2 Answers2

1

According to the doc example

Your command could use %STARTSWITH instead of like:

select * from person where name %STARTSWITH ?
Shago
  • 605
  • 4
  • 12
0

I finally figured out that all I had to do was to concatenate the "%" to the parameter being passed and it worked such as: param.Value = tbxName.Text.ToUpper() + "%";

  • Beware that using `like` you risk the user typing the `%` character on the text box, or leaving it blank. – Shago Jun 15 '16 at 17:19