这样一条SQL语句咋会出错哩???耽误大家几分钟时间帮忙看下!!谢了!!!

DoubleFrost DoubleFrost 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
有两个asp.net的页面,第一个页面是一些条件,选择条件点击查询按钮,就跳转到第二个页面,第二个页面把满足上个页面所选的条件的信息显示出来。第一个页面的代码是这样的,我用的Session传的值

Session["fbsj"] = txtfbsj.Text;
Session["zldw"] = txtzldw.Text;
Session["zlr"] = txtzlr.Text;
Session["zlzt"] = ddlzlzt.SelectedValue;
Session["bt"] = txtbt.Text;
Session["fkqx"] = txtfkqx.Text;
Response.Redirect("YanPanSelectResult.aspx");



请问第二个页面的查询语句要怎样写?这样写是错的:


SqlConnection con = SqlCon.GetSqlConnection();
SqlDataAdapter da = new SqlDataAdapter("select * from jh_zlxx where ((@fbsj is null or zlxx_fbsj=@fbsj) and (@zldw is null or zlxx_zldw=@zldw) and (@zlr is null or zlxx_zlr=@zlr) and (@zlzt is null or zlxx_zlzt=@zlzt))",con);
da.SelectCommand.Parameters.AddWithValue("@fbsj", Session["fbsj"]);
da.SelectCommand.Parameters.AddWithValue("@zldw",Session["zldw"]);
da.SelectCommand.Parameters.AddWithValue("@zlr",Session["zlr"]);
da.SelectCommand.Parameters.AddWithValue("@zlzt",Session["zlzt"]);
DataSet ds = new DataSet();
da.Fill(ds, "SelectResult");

gdvFaBu.DataSource = ds;
gdvFaBu.DataBind();


查询出来什么也没有。哪里错了啊??

...全文

相关推荐

评论 19
收藏 已收藏
分享
返回顶部
DoubleFrost
.NET社区 62,271 成员 668,968 内容