读书人

简单三层小疑点

发布时间: 2012-03-08 13:30:13 作者: rapoo

简单三层小问题
我在DAL层里写了个删除的方法
然后在BLL里调用方法
但在前台接收的ID不能被获取到
如果直接用 response.write(id)可以输出在页面,,
请问这是怎么回事呢。。我把我的dal方法 和bll方法和前台删除的代码贴出来 第一次学三层 不规范 请大家 多指教 。
dal

C# code
 /// <summary>       ///  删除一条数据根据用户ID       /// </summary>       /// <param name="DelModle"></param>       /// <returns></returns>       public bool Delete(Modle.UserInfos DelModle)       {           conn.Open();           string sql = "delete  * from UserInfos where UserId=@uid";           SqlCommand _cmd = new SqlCommand(sql, conn);           SqlParameter delCp = new SqlParameter("@uid", SqlDbType.Int);           delCp.Value = DelModle.UserId;           _cmd.Parameters.Add(delCp);           return _cmd.ExecuteNonQuery() > 0;           conn.Close();                 }

BLL调用
C# code
 public bool BLL_Del(Modle.UserInfos mu_del)        {            DAL.UserService _du = new UserService();            return _du.Delete(mu_del);        }

删除页面:
C# code
 int strid = Convert.ToInt32(Request.QueryString["id"]);                Modle.UserInfos mu = new Modle.UserInfos();                mu.UserId = Convert.ToInt32(strid);                BLL.UBLL bu = new BLL.UBLL();                bu.BLL_Del(mu);                Response.Write("删除成功!");


[解决办法]
int strid = Convert.ToInt32(Request.QueryString["id"]);

你打个断点,在这个位置看看有值没?
[解决办法]
string sql = "delete * from UserInfos where UserId=@uid";
我蛋疼。。这sql能执行?
[解决办法]
cmd.Commtext=CommandType.text;

#11楼的sql语句改成delete from UserInfos where UserId=@uid 再试试

读书人网 >asp.net

热点推荐