日期:2014-05-18  浏览次数:20422 次

跳转页面修改编号
有两个页面,第一个页面中有个文本框,一个ImageButton按钮。另一个页面是一个文本框和一个Button按钮。第一个页面中文本框的值是从数据库中用DataReader读取出来的。当我点击ImageButton的时候,跳转到第二个页面,此时第二个页面的文本框获取第一个页面文本框中的值。问题是我现在第二个页面里修改获取的值。怎么做?sql语句是什么???(传值我会)
下面是我写的代码:帮忙看看。先谢谢啦!

第一个页面的代码:
private void ImageButton_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
  string url; 
  url="patentid.aspx?pid=" + txtpid.Text ;
  Response.Redirect(url); 
}

第二个页面的代码:
private void Page_Load(object sender, System.EventArgs e)
{
  this.txtpid.Text=Request.QueryString["pid"]; 
}

private void Button_Click(object sender, System.EventArgs e)
{
  SqlConnection CnSql = new SqlConnection ("uid=sa;pwd=sa;database=patent;server=.");
  string sql ="select pid from patentInfo ";
  CnSql.Open();
  string sql1="update patentInfo set pid='"+this.txtpid.Text+"' where pid='"+Request.QueryStrin["pid"]+"'";
  SqlCommand cmd=new SqlCommand (sql1,CnSqlcmd.ExecuteNonQuery();
  CnSql.Close();
  Response.Write("<script>alert('修改成功!')</script>");
}

------解决方案--------------------
int i = cmd.ExecuteNonQuery();//改成这个.然后把i response.write出来看看是多少.