开发者

How to write select SQL to use like when using control parameter?

开发者 https://www.devze.com 2023-02-05 03:16 出处:网络
How to change to use like instead of = ? ([Card_no] = @Search) Moreover, if i want to show all in default, this method force to user to type
  1. How to change to use like instead of = ?

([Card_no] = @Search)

  1. Moreover, if i want to show all in default, this method force to user to type something first. How to show all in default when using control parameter?

    SelectCommand="SELECT [Serial_no], [Transaction_Date], [Card_no], [Company],[IsCredit], [Fee] FROM [CarPark] WHERE ([Card_no] = @Search) or ([Company] = @Search)"
    UpdateCommand="UPDATE [CarPark] SET
    Card_no=@Card_no,
    Company=@Company, 
    IsCredit=@IsCredit,
    Fee=@Fee
    WHERE Serial_no=@Serial_no">
    <UpdateParameters>
        <asp:Parameter Name="Card_no" Type="Str开发者_如何转开发ing" />
        <asp:Parameter Name="Company" Type="String" />
        <asp:Parameter Name="IsCredit" Type="Boolean" />
            <asp:Parameter Name="Fee" Type="Double" />
        </UpdateParameters>
        <SelectParameters>
        <asp:ControlParameter ControlID="Search_TextBox" DefaultValue="" Name="Search" 
                PropertyName="Text" Type="String" />
    </SelectParameters>    
    


Try this:

Card_no like '%{0}%'

Or if you must use named parameters:

Card_no like '%'+@search +'%'

0

精彩评论

暂无评论...
验证码 换一张
取 消