立即将已保存的数据从程序写入Access数据库. [英] Instant writing of saved data to an Access Database from the program.
问题描述
我正在寻找一种将Update命令产生的数据立即保存到* .accdb Access数据库文件的方法.现在,如果我在保存数据后退出程序,请再次运行它并打开数据库,保存的数据将存在.如果我在不先关闭程序的情况下从程序中打开另一个文件或相同文件,则我要保存的数据将丢失.我当前的更新方法:
I''m searching for a way to instantly save the data made by the Update command to an *.accdb Access Database file. As it stands now if I exit the program after having saved the data, run it again and open the database my saved data will be present. If I open another or the same file from the program without it closing first the data I asked to be saved is lost. My current update method:
OleDbCommandBuilder cmdBuilder = new OleDbCommandBuilder(daData);
daData.InsertCommand = cmdBuilder.GetInsertCommand();
daData.UpdateCommand = cmdBuilder.GetUpdateCommand();
daData.DeleteCommand = cmdBuilder.GetDeleteCommand();
DataTable tblData = (DataTable) (dgvData.DataSource);
try
{
daData.Update(tblData);
daData.Dispose();
}
catch (Exception error)
{
MessageBox.Show(error.Message);
tblData.Clear();
daData.Fill(tblData);
}
是否有从内存中清除保存的数据或强制程序立即更新Access数据库的方法?
Is there anyway to flush the saved data from memory or force the program to update the Access Database instantly?
推荐答案
请参见
OleDbTransaction.Commit方法(System.Data.OleDb)
see
OleDbTransaction.Commit Method (System.Data.OleDb)
这篇关于立即将已保存的数据从程序写入Access数据库.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!