- 积分
- 40165
- 好友
- 记录
- 主题
- 帖子
- 听众
- 收听
|
发表于 2013-4-7 14:17:39
|
显示全部楼层
如果你的Ds里只有一个表的话我建议你直接使用这个方法
[code=csharp]public DataSet CreateCmdsAndUpdate(string connectionString,
string queryString)
{
using (OleDbConnection connection = new OleDbConnection(connectionString))
{
OleDbDataAdapter adapter = new OleDbDataAdapter();
adapter.SelectCommand = new OleDbCommand(queryString, connection);
OleDbCommandBuilder builder = new OleDbCommandBuilder(adapter);
connection.Open();
DataSet customers = new DataSet();
adapter.Fill(customers);
//code to modify data in dataset here
adapter.Update(customers);
return customers;
}
}[/code]
当然也可以使用下面的方法,楼主自己对比一下吧,或者直接使用我的方法看看
[code=csharp]public DataSet CreateCmdsAndUpdate(string connectionString,
string queryString, string tableName)
{
using (OleDbConnection connection = new OleDbConnection(connectionString))
{
OleDbDataAdapter adapter = new OleDbDataAdapter();
adapter.SelectCommand = new OleDbCommand(queryString, connection);
OleDbCommandBuilder builder = new OleDbCommandBuilder(adapter);
connection.Open();
DataSet customers = new DataSet();
adapter.Fill(customers);
//code to modify data in dataset here
adapter.Update(customers, tableName);
return customers;
}
}[/code] |
|