mysql dataset_显示从MySQL填充DataSet的进步

bd96500e110b49cbb3cd949968f18be7.png

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

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();

}

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.

解决方案

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

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".

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值