显示从MySQL填充DataSet的进步 [英] Show progress of filling a DataSet from MySQL

查看:597
本文介绍了显示从MySQL填充DataSet的进步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发使用C#和MySQL数据库后端的应用程序。

I am currently developing an application using C# and a MySQL Database Backend.

要显示在一个DataGridView我的程序可能最终从数据库加载大量数据并添加到数据集。我希望能够以显示数据集的填充的进展,但不知道我怎么能去的地方是在数据库的引用。

My program could end up loading a large amount of data from the database and adding into a dataset to be displayed in a DataGridView. I want to be able to show the progress of the filling of the DataSet but not sure how I can get a reference to where it is in the database.

下面是我目前拥有的代码。

Below is the code that I currently have.

DatabaseWork dbase = new DatabaseWork();
try
{
  dbase.openConnection();
  MySqlDataAdapter myDA = new MySqlDataAdapter();
  myDA.SelectCommand = new MySqlCommand(query, dbase.conn);

  DataTable table = new DataTable();
  myDA.Fill(table);

  BindingSource bSource = new BindingSource();
  bSource.DataSource = table;

  tblDetails.DataSource = bSource;
  //tblGrid.Columns[0].Visible = false;
}
catch (MySqlException ex)
{
  dbase.displayError(ex.Message, ex.Number);
}
finally
{
  dbase.closeConnection();
}



我知道,我将不得不把这段代码到像一个Thread后台工作,但我怎样才能改变这种代码,以显示进度。

I know that I will have to put this section of code into a Thread like a Background Worker but how can I change this code to show the progress.

推荐答案

我会去与Stecya意见的落实进度酒吧作为一个大帐篷进度条。

I would go with Stecya comment an implement the progress bar as a marquee progress bar.

有关您能够更新数据填充的进度条,你必须知道你有多少记录具有事前,然后继续做类似包裹的DataAdapter知道它有多少条记录放入数据集,我不完全相信你可以做的。

For you to be able to update a progress bar of the dataset fill, you would have to know how many records you have beforehand, then keep do something like wrapping the dataAdapter to know how many records it has put into the dataset, which I'm not entirely sure you could do.

如果绑定的数据源需要花费大量的时间,以及,我将有一个状态消息的字幕栏一起,并检索记录更新,然后沿东西渲染记录的线。

If binding the dataSource takes a considerable amount of time as well, I would have a status message along with the marquee bar, and update it with "Retrieving records", then something along the lines of "Rendering records".

这篇关于显示从MySQL填充DataSet的进步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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