OleDbDataAdapter Ada = new OleDbDataAdapter();
DataTable table = (DataTable)DataList.DataSource;
//重新启动连接
String ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.Windows.Forms.Application.StartupPath + "/TEST.mdb";
//用Buider方法更新数据
using (OleDbConnection connection = new OleDbConnection(ConnectionString))
{
Ada.SelectCommand = new OleDbCommand("SELECT * FROM TestACCESS", connection);
OleDbCommandBuilder builder = new OleDbCommandBuilder(Ada);
Ada.UpdateCommand = builder.GetUpdateCommand();
try
{
//更新数据表数据时
Ada.Update(table);
//----这个地方会把所有的更新同步到数据库中--------------------
table.AcceptChanges();
MessageBox.Show("操作已成功!数据将全部被保存......", "系统消息", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2);
}
}
要写代码的,我给你个例子