本文介绍了DataAdapter未更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我以为我今天早上已将它排序但仍然存在问题。 我的应用程序有一个DataAccess类。 当它启动时,它: 连接到数据库(OLE DB) 如果它连接它使用带有SQL字符串的OleDbCommand和连接 它有一个带有命令 的DataAdapter然后用流数据填充DataSet的DataTable。 它为6个DataTables执行此操作, 然后它关闭连接。 一切正常,包括将DataSet保存到XML文件,如果 与DataBase的连接不成功,它从预先保存的XML重新加载最后知道的好的 DataSet。 我想要实现的是定期(每小时一次或按需) 从DataBase更新4个DataTables。 这个代码是: ConnectMyDB()子连接到数据库 如果MyDBConnected那么 如果没有HasDownloaded那么 ''做第一次下载的东西 否则 daMyTable1.Update(dsMyDataSet," MyDataTable1") daMyTable2.Update(dsMyDataSet," MyDataTable2") daMyTable3.Update (dsMyDataSet," MyDataTable3") daMyTable4.Update(dsMyDataSet," MyDataTable4") 结束如果 这运行没有错误,但DataSet没有更新任何在DataBase中发生的任何更改。 我错过了什么? 感谢Doug 解决方案 到 是 将 关闭 我 分配给 更改 到 Hi,I thought I had this sorted this morning but it is still a problem.My application has a DataAccess Class.When it starts, it:Connects to a DB (OLE DB)If it connects it uses an OleDbCommand with an SQL String and the connectionit has a DataAdapter with the commandthen it fills the DataSet''s DataTable with the streamed data.It does this for 6 DataTables,then it closes the connection.That all works fine including saving the DataSet to an XML file and if theconnection to the DataBase is not successful, it reloads the last know goodDataSet from the pre-Saved XML.What I am trying to achieve is to periodically (once an hour or on demand )update 4 of the DataTables from the DataBase.The code for this is:ConnectMyDB() sub to connect to the DatabaseIf MyDBConnected ThenIf Not HasDownloaded Then''Do the first download stuffElsedaMyTable1.Update (dsMyDataSet, "MyDataTable1")daMyTable2.Update (dsMyDataSet, "MyDataTable2")daMyTable3.Update (dsMyDataSet, "MyDataTable3")daMyTable4.Update (dsMyDataSet, "MyDataTable4")End IfThis runs without error but the DataSet is not updated with any of thechanges that have occured at the DataBase.Am I missing something?Thanks Doug 解决方案 to be to Set close I to a changes to 这篇关于DataAdapter未更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 09-02 19:53