conn.Open();
OleDbDataAdapter Bada = new OleDbDataAdapter("select * from " + cmdText, conn);//建立一个DataAdapter对象
OleDbCommandBuilder cb = new OleDbCommandBuilder(Bada);//这里的CommandBuilder对象一定不要忘了,一般就是写在DataAdapter定义的后面
cb.QuotePrefix = "[";
cb.QuoteSuffix = "]";
DataSet ds = new DataSet();//建立DataSet对象
Bada.Fill(ds, "demo");//填充DataSet
DataTable dt = ds.Tables["demo"];//建立一个DataTable对象,方便操作
foreach (DataRow tempRow in dt1.Rows)
{
DataRow dr = dt.NewRow();
dr.ItemArray = tempRow.ItemArray;//行复制
dt.Rows.Add(dr);
}
Bada.Update(ds, "demo");//用DataAdapter的Update()方法进行数据库的更新
原文地址:https://www.cnblogs.com/ruiyuan/p/11410406.html