private void btnsave_Click(object sender, System.EventArgs e)
{
//===修改记录===
string strsql,smallid;
smallid=TextBox3.Text;
                           
//(1)
                           //TextBox1.Text;标题
//FreeTextBox1.Text;内容 //strsql="select * from New where newid="+smallid;
//(new link()).Uxsql(strsql,"New");
                            怎么将(1)这两个字段更新到New数据库中去? }

解决方案 »

  1.   

    string strconn="Data Source=localhost;UID=sa;PWD=;DATABASE=数据库名称"/
    //连接本地计算机的MMS数据库
    SqlConnection cn= new SqlConnection (strconn);
    cn.Open ();
    string mysql= "update //更新的sql语句";
    //创建Command对象
    SqlCommand cm=new SqlCommand  (mysql,cn);
    //执行ExecuteReader ()方法
    SqlDataReader dr=cm.ExecuteReader ();  
      

  2.   

    SqlConnection myConnection = new SqlConnection(strConn);
    string strsql="Update New set 标题='"+ TextBox1.Text +"',内容='"+ FreeTextBox1.Text +"' where newid='"+ smallid +"'";
    SqlCommand myCommand = new SqlCommand(strsql,myConnection);
    myConnection.Open();
    myCommand.ExecuteNonQuery();
      

  3.   

    这样不容易出错
    string strsql="Update New set 标题=@Title,内容=@Content where newid=@ID";SqlCommand objComm = new SqlCommand(strsql,objConn);
    objComm.Parameters.Add("@Title",   TextBox1.Text);
    objComm.Parameters.Add("@Content", FreeTextBox1.Text);
    objComm.Parameters.Add("@ID",      值);objConn.Open()
    objComm.ExecuteNonQuery()
    objConn.Close()