我做的一个修改
本来就这样输入来修改数据库中的记录是好好的
SqlConnection conn=new SqlConnection(ConfigurationSettings.AppSettings["dsn"]);
string sql="update guestbook set speak='"+this.edspeak.Text+"',topic='"+this.edtopic.Text+"' where id=" +Request.QueryString["id"];
conn.Open();
   SqlCommand comm=new SqlCommand(sql,conn);
   comm.ExecuteNonQuery();
   conn.Close();
   Response.Redirect("index.aspx");
但是当我把数据库中的值用如下语句提取到textbox
 string strSql="select topic,speak from guestbook where id=" +Request.QueryString["id"];
       conn.Open();
          SqlCommand mycommand=new SqlCommand(strSql,conn);
  SqlDataReader myReader=mycommand.ExecuteReader();
                           if(myReader.Read())
{
 this.edtopic.Text=myReader.GetValue(0).ToString();
this.edspeak.Text=myReader.GetValue(1).ToString();   }
  conn.Close();
  myReader.Close();                       mycommand.Dispose();
然后再对这些值进行编辑,后提交则修改后还数据库值是一点都没有变!
我的前端页面很简单,就是两个textbox控件
大家说说这是什么原因啊????
急啊!

解决方案 »

  1.   

    什么呀
    select 怎么会改变---()
    前面确实updata
      

  2.   

    //先**********************************
    string strSql="select topic,speak from guestbook where id=" +Request.QueryString["id"];
           conn.Open();
              SqlCommand mycommand=new SqlCommand(strSql,conn);
      SqlDataReader myReader=mycommand.ExecuteReader();
                               if(myReader.Read())
    {
     this.edtopic.Text=myReader.GetValue(0).ToString();
    this.edspeak.Text=myReader.GetValue(1).ToString();   }
      conn.Close();
      myReader.Close();                       mycommand.Dispose();
    //后******************************************************
    SqlConnection conn=new SqlConnection(ConfigurationSettings.AppSettings["dsn"]);
    string sql="update guestbook set speak='"+this.edspeak.Text+"',topic='"+this.edtopic.Text+"' where id=" +Request.QueryString["id"];
    conn.Open();
       SqlCommand comm=new SqlCommand(sql,conn);
       comm.ExecuteNonQuery();
       conn.Close();
       Response.Redirect("index.aspx");
      

  3.   

    楼主把读出后要更新的SQL语句输出看一下,设置断点看一下执行没有