日期:2014-05-18 浏览次数:20414 次
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:CKCCon %>" SelectCommand="SELECT * from Products WHERE [csProductName] like @csProductName or [csSpecification] like @csProductName"> <SelectParameters> <asp:QueryStringParameter Name="csProductName" QueryStringField="pd" Type="String" /> </SelectParameters> </asp:SqlDataSource> </div> <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px" AutoGenerateRows="False" DataSourceID="SqlDataSource1"> <Fields> <asp:BoundField DataField="csProductName" HeaderText="csProductName"
SELECT * from Products WHERE [csProductName] like '%@csProductName%' or [csSpecification] like '%@csProductName%'
------解决方案--------------------
SelectCommand="SELECT * from Products WHERE [csProductName] like '%@csProductName%' or [csSpecification] like '%@csProductName%'">
==>>
SelectCommand="SELECT * from Products WHERE [csProductName] like '%" + @csProductName + "%' or [csSpecification] like '%" + @csProductName + "%'">
------解决方案--------------------
SelectCommand="SELECT * from Products WHERE [csProductName] like '%'+@csProductName+'%' or [csSpecification] like '%'+@csProductName+'%'