首页 新闻 搜索 专区 学院

c# 参数化问题? 急

0
悬赏园豆:5 [已解决问题] 解决于 2012-08-17 11:37

string sql_filelist = "";
        SqlParameter[] cmd_filelist =new SqlParameter[1];
        if (Request.QueryString["pdid"]!=null)
        {
             sql_filelist = "select Pid,Ptitle,Pcontent,Pnum,Psize,Pprice,PDID,PDN,PXID,PXN,dpic,Ppic,Paddtime from ProductList where PDID=@PDID order by Pid desc";
             cmd_filelist={ new SqlParameter("@PDID", Request.QueryString["pdid"]) };
        }
        if (!string.IsNullOrEmpty(Request.QueryString["pxid"]))
        {
             sql_filelist = "select Pid,Ptitle,Pcontent,Pnum,Psize,Pprice,PDID,PDN,PXID,PXN,dpic,Ppic,Paddtime from ProductList where PxID=@PxID order by Pid desc";
           cmd_filelist ={ new SqlParameter("@PxID", Request.QueryString["PxID"]) };
        }
        if (!string.IsNullOrEmpty(Request.QueryString["pbid"]))
        {
             sql_filelist = "select Pid,Ptitle,Pcontent,Pnum,Psize,Pprice,PDID,PDN,PXID,PXN,dpic,Ppic,Paddtime from ProductList where PBrandID=@PbID order by Pid desc";
             cmd_filelist ={ new SqlParameter("@PbID", Request.QueryString["PbID"]) };
        }

 

这样写老是报多了"}" ,不知道为什么?

C#
jason2013的主页 jason2013 | 小虾三级 | 园豆:1998
提问于:2012-08-16 10:24
< >
分享
最佳答案
0

是编译报错,还是运行时报错?

收获园豆:5
Launcher | 高人七级 |园豆:45045 | 2012-08-16 10:28

jason2013 | 园豆:1998 (小虾三级) | 2012-08-16 10:33

@wydycg: 编译器错误消息: CS1525: 无效的表达式项“{”

jason2013 | 园豆:1998 (小虾三级) | 2012-08-16 10:37

@wydycg: 那你这样写:

cmd_filelist = new Sqlparameter[]{ new SqlParameter("@PbID", Request.QueryString["PbID"]) };

Launcher | 园豆:45045 (高人七级) | 2012-08-16 10:39
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册