DataSet问题
大家都知道,DataSet不是直接连接数据库的,而是存储在内存中,当我们改变了DateSet的值时,如何能够保存到数据库中?
能具体点不?
static private DataSet CreateCommandAndUpdate(
string connectionString,
string queryString)
{
DataSet dataSet = new DataSet();
using (OleDbConnection connection =
new OleDbConnection(connectionString))
{
connection.Open();
OleDbDataAdapter dataAdapter =
new OleDbDataAdapter();
dataAdapter.SelectCommand =
new OleDbCommand(queryString, connection);
OleDbCommandBuilder commandBuilder =
new OleDbCommandBuilder(dataAdapter);
dataAdapter.Fill(dataSet);
// 在这里写代码修改dataset里的数据.
dataAdapter.Update(dataSet);
}
return dataSet;
}