110,549
社区成员
发帖
与我相关
我的任务
分享
public static OleDbDataAdapter AdapterUpdate(string SelectString, DataTable tableName,string connectionString)
{
OleDbDataAdapter Adapter = new OleDbDataAdapter();
using (OleDbConnection connetion = new OleDbConnection(connectionString))
{
Adapter.SelectCommand = new OleDbCommand(SelectString, connetion);
OleDbCommandBuilder builder = new OleDbCommandBuilder(Adapter);
Adapter.UpdateCommand = builder.GetUpdateCommand();
Adapter.Update(tableName);
table.AcceptChanges();
return Adapter;
}
}
//调用
DataTable table = (DataTable)dataGridView1.DataSource;
AdapterUpdate(SelectSql, table,connectionString)//SelectSql为查询语句 connectionString //为数据库连接语句