日期:2014-05-17 浏览次数:20781 次
OleDbDataAdapter da = new OleDbDataAdapter(sql, myConn);
DataSet dsnew = new DataSet();
da.Fill(dsnew,"t_mytable");//我的数据库中表名叫t_mytable
//设置主键
dsnew.Tables[0].PrimaryKey = new DataColumn[] { dsnew.Tables[0].Columns[0] };
OleDbCommandBuilder custCB = new OleDbCommandBuilder(da);
da.InsertCommand = custCB.GetInsertCommand();
dsnew = ds;///ds就是我从文件中读取的DataSet
da.Update(dsnew);
dsnew.AcceptChanges();