数据集更新或刷新

编程入门 行业动态 更新时间:2024-10-26 03:37:48
本文介绍了数据集更新或刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在写一个多用户C#Windows应用程序, 如果有人在他们的机器上更改/添加他们的应用程序的记录,我的问题就会出现, 除非调用tableadapter.fill,否则它不显示在另一台机器上。 如果我在计时器上填充表适配器,我的列表框会闪烁。 /> 任何想法如何在我的数据集中刷新我的数据而不会导致应用程序延迟。试过背景工作也没有成功。 不知怎的,我需要看看数据集是否与数据库相同,如果没有它应该更新。并且没有延迟申请。我正在使用Firebird数据库。 谢谢

Hi, I'm writing a multiple user C# Windows Application, my problem comes in if someone else changes/adds a record on their app on their machine, it is not showing on the other machine unless the tableadapter.fill is called. If i fill the table adapter on a timer, my listbox is flickering. Any ideas how i can refresh my data in my dataset without causing delays on the app. Tried backgroundworker aswell with no success. Somehow i need to see if the dataset is the same as the DB, if not it should update. and with no delays on the application. I am using a Firebird Database. Thanks

推荐答案

刷新数据集您可以重置数据集并重新填充。 To refresh dataset You can Reset dataSet and fill it again. this.YourDataSet.Reset(); this.YourTableAdapter.Fill(this.YourDataSet.table);

此代码不使用tableadapter,但使用dataadapter。请使用Clear()函数清除数据集,然后填充()数据集。我使用了MS Access数据库与OleDB连接 This code is without using tableadapter, but with dataadapter.Please clear your dataset with Clear() function and then Fill() the dataset.I have used MS Access Database with OleDB Connection string con1 = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Documents and Settings\sam\my documents\visual studio 2010\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Database1.accdb"; string query1 = "SELECT * FROM Table2"; OleDbDataAdapter da1 = new OleDbDataAdapter(query1, con1); OleDbCommandBuilder cmd = new OleDbCommandBuilder(da1); da1.Update(database1DataSet2.Table2); this.database1DataSet2.Table2.Clear(); //clears the dataset da1.Fill(database1DataSet2.Table2);

更多推荐

数据集更新或刷新

本文发布于:2023-10-30 23:00:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1544253.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!