protected void Button1_Click(object sender, EventArgs e)
    {
        OleDbConnection connstr = DBConnections.DBConnections.createConnection();
        connstr.Open();
        string bigclassname = Convert.ToString(this.TextBox1.Text);
        string bigid = Convert.ToString(this.TextBox2.Text);
        string sql = "update Hover_BigClass_New set BigClassName='" + bigclassname + "',BigID='" + bigid + "'where BigClassID =" + Request["bigclassid"];
        OleDbCommand cmd = new OleDbCommand();
        cmd.Connection = connstr;
        cmd.CommandText = sql;        cmd.ExecuteNonQuery();
        Response.Write("<script language='javascript'>alert('提交成功!');window.location.href='classmanage.aspx';</script>");
        connstr.Close();
  
        
    }
其中Request["bigclassid"]为数字,没有提示错误,数据也没有变化,就是没反应。。高手指点。

解决方案 »

  1.   

    你的sql文错了吧,打个断点看看,走下去什么结果。where 前需要一个空格。
      

  2.   

    where 条件写错了把??断点看看sql 是什么值
      

  3.   

    建议 用参数 parameter
    比字符串+++的  容易看~我现在就最看不了字符串++的
      

  4.   

    你的BUTTON单击有提交FORM吗?为什么用REQUEST取啊?直接从控件取值吧..你先SHOW一下SQL吧...
      

  5.   

    你加一句
      Response.Write(sql);
    看看你要执行的sql语句是什么,再贴出来给大家看看
      

  6.   

    update Hover_BigClass_New set BigClassName='dd',BigID='1' where BigClassID =7 
      

  7.   

    string sql = "update Hover_BigClass_New set BigClassName='" + bigclassname + "',BigID='" + bigid + "'where BigClassID =" +Conver.ToInt32( Request["bigclassid"]); 
      

  8.   

    你确定运行中没有错误?那么Response.Write(" <script language='javascript'>alert('提交成功!');window.location.href='classmanage.aspx'; </script>"); 
    这句应该是过了。
    可是你刚才说没有反应。不知道是怎么回事。。
      

  9.   

    哦,你把sql拿出来,单独在sql里面执行看看有什么结果。即update Hover_BigClass_New set BigClassName='dd',BigID='1' where BigClassID =7 
    有变化没有?
      

  10.   

    发现问题所在了。。原来,修改过的。比如原来是dd,现在我修改成dddd,它取的数据还是原来的dd..
      

  11.   

    不明白。为什么
      string bigclassname = Convert.ToString(this.TextBox1.Text);
                string bigid = Convert.ToString(this.TextBox2.Text);
    这两句不能正确接收数据。
      

  12.   

    问题解决了。贴上全部代码
    public partial class admins_editClass : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
         if (!IsPostBack)
            {
            OleDbConnection connstr = DBConnections.DBConnections.createConnection();
            connstr.Open();        string sql1 = "select * from Hover_BigClass_New where BigClassID="+ Request["bigclassid"];
            OleDbCommand cmds = new OleDbCommand(sql1,connstr);
            OleDbDataReader dr=cmds.ExecuteReader();
         
            if(dr.Read())
            {
                this.TextBox1.Text = dr["BigClassName"].ToString();
                this.TextBox2.Text = dr["BigID"].ToString();
            }        dr.Dispose();
            dr = null;
            connstr.Close();     }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
           
                OleDbConnection connstr = DBConnections.DBConnections.createConnection();
                connstr.Open();
                string bigclassname = Convert.ToString(this.TextBox1.Text);
                string bigid = Convert.ToString(this.TextBox2.Text);
                string sql = "update Hover_BigClass_New set BigClassName='" + bigclassname + "',BigID='" + bigid + "' where BigClassID =" + Convert.ToInt32(Request["bigclassid"]);
                OleDbCommand cmd = new OleDbCommand();
                cmd.Connection = connstr;
                cmd.CommandText = sql;
                //Response.Write(sql);
                cmd.ExecuteNonQuery();
               Response.Write("<script language='javascript'>alert('提交成功!');window.location.href='classmanage.aspx';</script>");
                connstr.Close();
           
            
        }
    }