修改信息的update语句 执行之后 数据库没有更新 求大侠指教!
protected void Button1_Click(object sender, EventArgs e)
    {
        SqlCommand sqlcomm;
        sqlcomm = new SqlCommand("update THypertensionManagement set fName='" + fName.Text + "',fBeginTime='" + fBeginTime.Text + "' where fID=" + LBfID.Text, sqlconn);
                
        if (sqlcomm.ExecuteNonQuery() > 0)
        {
            Response.Write("<script language=javascript>alert('修改成功!')</script>");
        
        }
        else
        
        {
           Response.Write("<script language=javascript>alert('修改失败!')</script>");
         
        }    }

解决方案 »

  1.   

    建议你在SQL Server中执行一下你的语句,看看是不是能成功。
      

  2.   

    response.write(("update THypertensionManagement set fName='" + fName.Text + "',fBeginTime='" + fBeginTime.Text + "' where fID=" + LBfID.Text)
    输入一下sql语句,在数据库中执行看看
      

  3.   

    加断点,看看生成的sql语句,拿到sql查询分析器中去测试
      

  4.   

    对,调式运行,看看"update THypertensionManagement set fName='" + fName.Text + "',fBeginTime='" + fBeginTime.Text + "' where fID=" + LBfID.Text这句话的实际值到底是什么,最好这样:string strsql="update THypertensionManagement set fName='" + fName.Text + "',fBeginTime='" + fBeginTime.Text + "' where fID=" + LBfID.Text;sqlcomm = new SqlCommand(strsql, sqlconn);便于调试,把strsql拷贝到数据库查询分析器执行,问题会一目了然
      

  5.   

    where 后面的条件我觉得没错啊 where 后面的格式怎么样 条件是 fID= LBfID.Txet
      

  6.   

    sqlconn不在事件内,你怎么调用,还是说是public的,实例一个conn
      

  7.   

    fID=" + LBfID.Text?
    看这个LZ的意思是FID是int类型的吧LZ把条件改下
    fID=" + int.parse(LBfID.Text.Trim())...
      

  8.   

    看LZ意思 fid是int类型的吧
    这样改 fID= "+int.parse(LBfID.Txet.Trim())...
      

  9.   


    写程序,不能“我觉得没错”,设置断点,你调试运行到这句:
    string strsql="update THypertensionManagement set fName='" + fName.Text + "',fBeginTime='" + fBeginTime.Text + "' where fID=" + LBfID.Text;把strsql实际值拷贝出来,粘贴到数据库查询分析器里执行!
      

  10.   

    数据库fBeginTime是不时间格式如果是最好转换一下
    DateTime ft=Convert.TodateTime(fBeginTime.Text)fBeginTime='" + ft + "'
      

  11.   

    加断点,看看生成的sql语句,拿到sql查询分析器中去测试