Update方法如何使用啊,看书上说是和CommandBuilder联合起来用的?
我没用过不知如何使用啊,请各位高手帮帮忙!写的示例,在此先谢过了!

解决方案 »

  1.   

    不知道你连接的是什么数据库,oracle吗?
      

  2.   

    呵呵  昨天才写了一个!给你发个简单的
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Data.SqlClient;namespace 实验
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private SqlDataAdapter da;
            private DataSet ds;
            private SqlCommandBuilder builder;
            private void Form1_Load(object sender, EventArgs e)
            {
                using (SqlConnection con = new SqlConnection("server=(local);" + "integrated security=SSPI;" + "database=henry"))
                {
                    da = new SqlDataAdapter("select * from login", con);
                    builder = new SqlCommandBuilder(da);
                    ds = new DataSet();
                    da.Fill(ds, "login");
                    dataGrid1.DataSource = ds;
                    dataGrid1.DataMember = "login";
                }
            }        private void button1_Click(object sender, EventArgs e)
            {
                da.Update(ds, "login");
            }
        }
    }
      

  3.   

    string sqlstr = "select * from tablename ";
    SqlDataAdapter da = new SqlDataAdapter(sqlstr);
    DataSet ds = new DataSet();
    da.Fill(ds, "tablename");
    SqlCommandBuilder cb = new SqlCommandBuilder(da);/*对DATASET数据修改等等*/da.Update(ds);
    ds.AcceptChanges();
      

  4.   

    恩,挺有意思的,那么这个能直接更新DataGrid中的数据到数据库吗?
      

  5.   

    MSDN 上好象是英文的 看不懂啊