修改单元格的值,更新数据库
  SqlConnection cn = new SqlConnection( "server=192.168.1.5;database=test;uid=sa;pwd=sa");
        SqlCommand cm = new SqlCommand();
        DataSet ds = new DataSet();
        SqlDataAdapter da = new SqlDataAdapter();
        SqlCommandBuilder cb = new SqlCommandBuilder();  private void Form1_Load(object sender, EventArgs e)
        {
            cm = new SqlCommand("select * from table", cn);
            da = new SqlDataAdapter(cm);
            da.Fill(ds, "table");
            this.dataGridView1.DataSource = ds.Tables["table"];
        }//更新数据库
 private void button2_Click(object sender, EventArgs e)
        {            cm = cn.CreateCommand();
            cm.CommandText = "select * from table";
            da = new SqlDataAdapter(cm);
            cb = new SqlCommandBuilder(da);
            da.Update(ds.Tables[0]);
            this.dataGridView1.Update();
}