Populating the SQLDatasource SelectCommand



如何将此字符串放入选择命令中?

String SqlC = "select * from dbo.FindIt where " + SqlStr;

对象用来填充SelectCommand:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
ConnectionString="<%$ ConnectionStrings:M3ConnectionString %>" 
SelectCommand = SqlC >
</asp:SqlDataSource>
protected void Page_Load(object sender, EventArgs e)
{
var runx = Request.QueryString.GetValues("run") != null ? Request.QueryString.GetValues("run")[0] : "";
if (runx != "") {
var sqlStr = "RUN= '" + Runx + "'";
var sqlC = "select * from dbo.FindIt where " + sqlStr;
SqlDataSource1.SelectCommand = sqlC;
}
else {
// TODO: Handle this situation.
}
}

最新更新