Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 如何在SelectCommand中使用两个QueryStringParameter_Asp.net - Fatal编程技术网

Asp.net 如何在SelectCommand中使用两个QueryStringParameter

Asp.net 如何在SelectCommand中使用两个QueryStringParameter,asp.net,Asp.net,我想知道如何将两个QueryStringParameter从两个不同的页面传递到SelectCommand <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:con %>" SelectCommand="SELECT * FROM [admin_video] where c_id=@c_id OR c_name=@c_name" >

我想知道如何将两个
QueryStringParameter
从两个不同的页面传递到
SelectCommand

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:con %>" SelectCommand="SELECT * FROM [admin_video] where c_id=@c_id OR c_name=@c_name" >
    <SelectParameters>
         <asp:QueryStringParameter  Name="c_id" QueryStringField="id1" DbType="Int32"/>
         <asp:QueryStringParameter  Name="c_name" QueryStringField="id2" />

    </SelectParameters>
 </asp:SqlDataSource>

页码:1

您需要像这样修改SQL命令:

SELECT * FROM [admin_video] where c_id=IsNULL(@c_id,c_id) OR c_name=IsNULL(@c_name, c_name)

我从两个不同的页面传递两个字符串,因为存在一些条件。然后,您需要更多地分享两个页面的含义。您可以使用第一页中的会话变量,您可以在第2页上阅读。我在我的问题中写道,我正在从两个不同的页面传递
StringPerameter
。您可以看到
SelectCommand
。数据库的两个属性都在同一个表中,但我想匹配其中一个字符串,因为我在查询中写入
。用户可以从另外两个具有查询字符串的页面访问该页面。因此,请告诉我,如果用户希望使用
ID1
Page1
访问该页面以匹配
C\u ID
,或者使用
ID2
Page2
访问该页面以匹配
C\u NAME
,那么您需要修改SQL。您需要确保在用户输入时传递null没有指定任何内容。