user1046415
user1046415

Reputation: 789

Like operator in SQL Query in SQL Datasource

I have to use like operator for SQL Command in SQL Datasource, but it is not working. Did some one run into the issue? Please Advise.

<asp:SqlDataSource ID="gridSource" runat="server" ConnectionString="<%$ ConnectionStrings:connectionString %>"
     SelectCommand=" select * from [test where domain like '%@DomainID%'">
    <SelectParameters>
        <asp:ControlParameter Name="DomainID" PropertyName="SelectedValue" ControlID="ddlcu"></asp:ControlParameter>
    </SelectParameters>
</asp:SqlDataSource>

Upvotes: 1

Views: 986

Answers (2)

Renats Stozkovs
Renats Stozkovs

Reputation: 2605

Do this:

WHERE Name LIKE '%' + @nameparam + '%'"; 

Upvotes: 4

user1046415
user1046415

Reputation: 789

      where  Domain LIKE '%' + @DomainID + '%'" >

we need send this way in order to get the like operator work.Thanks

Upvotes: 1

Related Questions