public class TestModule :System.Web.IHttpModule   
    {
        #region IHttpModule 成员        public void Dispose(){ }        public void Init(System.Web.HttpApplication context)
        {
           context.BeginRequest+=new EventHandler(context_EndRequest);
        }
        public void context_EndRequest(object sender, EventArgs e)
        {
            HttpApplication ha = (HttpApplication)sender;
            string path = ha.Context.Request.Url.ToString();
            if(path.indexof("GoodsID")!=-1)
            {
                using(sqlconnection conn = new sqlconnection(@"Data Source=.\Sql2005;Initial Catalog=MyShop;uid = sa;pwd=123"))
                {
                             sqlcommand cmd = new sqlcommand("update GoodsInfo set Goods_Weight=10 where GoodsID=@GoodsID");
                             cmd.parameter.addwidth("@GoodsID",convert.toint32(ha.context.Request.QueryString["GoodsID"]));
                             cmd.ExecuteNoQuery();
                 }
            }            
        }
        #endregion
    }
为什么浏览页面的时候数据库没改动?
是不是ha.context.Request.QueryString["GoodsID"]取不到?

解决方案 »

  1.   

    你为什么不下断点,用了using就看不到错误,把using先去掉
      

  2.   

    sqlcommand cmd = new sqlcommand("update GoodsInfo set Goods_Weight=10 where GoodsID=@GoodsID",conn);
      

  3.   

    因为是写在一个类库里的!
    然后引用了生成的bll
    断点看不了额
    sqlcommand是刚手写上去的!忘了写后面的语句今天杯具的发现家里电脑上的usb接口坏了- -
    只能手动敲了