P
Paul Wolpe
Is there a way to use a like statement with a SqlParameter and the
Microsoft Data Access Block?
I would like to be able to do this:
int CustomerID = (int) SqlHelper.ExecuteScalar(
ConfigurationSettings.AppSettings["connectionString"],
CommandType.Text,
@"select CustomerId
from Northwind..Customers
where ContactName like '%@customer_name%'",
new SqlParameter("@customer_name",CustomerName)
);
Since the DAB already quotes my SqlParameter, SqlServer ends up seeing
extra quote signs. Something like:
where ContactName like '%'John Doe'%'
Any thoughts?
-Paul
Microsoft Data Access Block:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/daab-rm.asp
Microsoft Data Access Block?
I would like to be able to do this:
int CustomerID = (int) SqlHelper.ExecuteScalar(
ConfigurationSettings.AppSettings["connectionString"],
CommandType.Text,
@"select CustomerId
from Northwind..Customers
where ContactName like '%@customer_name%'",
new SqlParameter("@customer_name",CustomerName)
);
Since the DAB already quotes my SqlParameter, SqlServer ends up seeing
extra quote signs. Something like:
where ContactName like '%'John Doe'%'
Any thoughts?
-Paul
Microsoft Data Access Block:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/daab-rm.asp