developernetwork
asked on
SQL LIKE Clause With CommandParamters in ASP.NET
SelectCommand="SELECT id, firstname, lastname, code, phone FROM dbo.Customers WHERE (firstname LIKE @firstname '%') OR (lastname LIKE @lastname)"
I need to be able to look up Firstnames and lastnames using the Like% clause ( text/wildcard ). How can I implement this wit the command paramters in ASP.NET?
I need to be able to look up Firstnames and lastnames using the Like% clause ( text/wildcard ). How can I implement this wit the command paramters in ASP.NET?
ASKER
No, there is no such method available.
ASKER
And the '%' doesn't work even if I hardcode it using the SelectParameters collection.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you use objectdatasource in 2.0 then you do something like this.
<asp:ControlParameter DefaultValue="%" Name="firstname" ControlID="Dropdownlist1" Type="String" />
<asp:ControlParameter DefaultValue="%" Name="firstname" ControlID="Dropdownlist1" Type="String" />
SelectCommand.Parameters.A
SelectCommand.Parameters.A
I think that might work.