用于获取记录表格db的进度条? [英] Progress bar for fetch a records form db?
本文介绍了用于获取记录表格db的进度条?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用进度条来显示我正在从数据库中检索记录需要5到10分钟,这样如果程序在Windows应用程序中仍然运行,用户就不会混淆请帮助我
到目前为止我在获取数据表格后已经完成了进度条
I want to use a progressbar to show that I'm retrieving the records from the database which take 5 to 10 min so that the user wont be confuse if the program is still running or not in windows Application?? pls help me
till now i have done progress bar after fetching the data form db
If (todate(2).ToString() = year) Then
'ds = objclient.FnGetFuelSurcharge()
'this the function were the query executes
ProgressBar2.Maximum = ds.Rows.Count<
If (ds.Rows.Count = 0) Then
RadMessageBox.Show("No Record found", Configuration.ConfigurationManager.AppSettings("messageBoxTitle"), MessageBoxButtons.OK, RadMessageIcon.Error)
Else
Dim _excel As New Microsoft.Office.Interop.Excel.Application
Dim wBook As Microsoft.Office.Interop.Excel.Workbook
Dim wSheet As Microsoft.Office.Interop.Excel.Worksheet
wBook = _excel.Workbooks.Add()
wSheet = wBook.ActiveSheet()
Dim dt1 As System.Data.DataTable = ds
Dim dc As System.Data.DataColumn
Dim dr As System.Data.DataRow
Dim colIndex As Integer = 0
Dim rowIndex As Integer = 0
ProgressBar2.Visible = True
For Each dc In ds.Columns
colIndex = colIndex + 1
_excel.Cells(1, colIndex) = dc.ColumnName
Next
For Each dr In ds.Rows
rowIndex = rowIndex + 1
colIndex = 0
For Each dc In ds.Columns
colIndex = colIndex + 1
_excel.Cells(rowIndex + 1, colIndex) = dr(dc.ColumnName)
Next
ProgressBar2.Value = rowIndex
ProgressBar2.Refresh()
Next
progressbar2.visiable= false
推荐答案
具体方法取决于您检索记录的方式。但是,有一个事件可以帮助您:从SQL Server报告进度 [< a href =http://geekswithblogs.net/mrnat/archive/2004/09/20/11431.aspxtarget =_ blanktitle =New Window> ^ ]
它是在C#中,但它是非常简单明了的代码。
[edit]
鉴于您现在显示的代码,您应该考虑将现有代码移动到BackgroundWorker [ ^ ] - 该链接包含一个示例。您所要做的就是更新ProgressChanged事件中的进度条,并在循环中调用ReportProgress。
[/ edit]
Exactly how you do this depends on how you are retrieving the records. But, there is an event which may help you: Report progress from SQL Server[^]
It's in C#, but it's pretty simple and obvious code.
[edit]
Given the code you are now showing, you should consider moving the existing code into a BackgroundWorker[^] - the link includes an example. All you have to do then is update the progress bar in the ProgressChanged event, and call ReportProgress in your loop.
[/edit]
>
这篇关于用于获取记录表格db的进度条?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文