如何在dataadapter填充数据表时使用进度条 [英] How to use progressbar while dataadapter is filling a datatable

查看:104
本文介绍了如何在dataadapter填充数据表时使用进度条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


让我说,我有我的后端数据库表中有数千条记录。我想将该表格带入vb.net。


使用:


myAdapter.fill(mydata)


上面的命令工作正常,但是在从数据库加载记录时(执行上面的命令时),应用程序就像挂起几秒钟一样,具体取决于要检索的记录数量。我想设置进度条,直到它完成将
数据加载到datatable。我应该在哪里放置进度条增加值的代码?

解决方案

您好,


处理此问题的真正方法是仅加载一个用户一次可以使用的数据,或者为用户提供从数据库中搜索数据的方法,显示它而不是一次加载大量数据。 / p>

使用TableAdapter对象的许多缺点之一是没有订阅事件来处理你的任务。


一个简单的方法就是要在表单上隐藏进度条,在执行填充操作之前使其可见,将样式设置为Marquee,填充后的下一行将隐藏进度条b)在填充之前显示表单然后
填写后处理表单。


保持简单,显示Progressbar或表单后的行,使用Application.DoEvents(这通常不赞成,但在这里没问题)。


另一种方法是使用BackGroundWorker组件,启动组件然后启动进度条操作或显示子表单。


最后,这里的基本问题是填充方法是同步的,没有事件可以用来做正确的显示进度,而其他形式的数据处理例如使用托管数据提供程序获取控制权然后您可以控制负载的响应速度
但加载时间较慢。 


 


Let say, I have thousands of records in my back end database table. I want to bring that table into vb.net.

Using:

myAdapter.fill(mydata)

Above command works perfectly, but while loading records from database ( while executing above command), the application is like hanging for seconds depending on how many records count to be retrieved. I want to set progress bar until it finished loading data to datatable. Where should I put the code where progress bar will increment value?

解决方案

Hello,

The true way of handling this is to only load data that one user can work with at a time or provide a method for the user to search for data from the database, display it rather than load a great deal of data at one time.

One of the many downsides to working with TableAdapter objects is that there are no events to subscribe to for dealing with your task.

A simple approach would be to have a progressbar hidden on the form, make it visible right before performing the Fill operation have the style set to Marquee, the next line after fill would hide the progress bar b) display a form right before the Fill then dispose the form after the fill.

Keeping with simple, the line after showing the Progressbar or the form, use Application.DoEvents (something that is generally frowned upon but okay here).

Another approach would be to use a BackGroundWorker component, start the component then start the progress bar operation or displaying of the child form.

In closing, the base issue here is the Fill method is synchronous with no events to tie into for doing a proper show progress while other forms of working with data e.g. using a managed data provider to take control then you would have control over the responsiveness of the load but with a slower load time. 

 


这篇关于如何在dataadapter填充数据表时使用进度条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆