Solved

How to calculate the time it would take to fill a dataset vb.net 2003??

Posted on 2007-03-23
6
388 Views
Last Modified: 2010-04-23
Experts, is there anyway to calculate the time it would take to connect to a database and fill a dataset using vb.net?
What I am trying to do is use a progress bar to show the progress of a database connect and retrieval of data, what I would need is to know how long before hand it would take to execute this line of code
ora.fill(ds, "Table1)

Once I got the "time" I could set a  timers intervals based on the "time" divided by the max value of the progress bar.   Any ideas on how to do this?

  Dim ssql As String = "select [Part#] as PartNumber, SerialNumber, AutoNumberID, Quantity from DailyBuildList " & _
                "Where Uploaded = 0"
            Dim ora As OleDbDataAdapter = New OleDbDataAdapter(ssql, accessconn)
            Dim org, status As Integer
            Dim dr As DataRow
                ora.Fill(ds, "Table1")
0
Comment
Question by:tentavarious
6 Comments
 
LVL 35

Expert Comment

by:YZlat
ID: 18782488
Dim ssql As String = "select [Part#] as PartNumber, SerialNumber, AutoNumberID, Quantity from DailyBuildList " & _
                "Where Uploaded = 0"
Dim startTime, endTime as DateTime
Dim diff as Integer
startTime=Datetime.Now
            Dim ora As OleDbDataAdapter = New OleDbDataAdapter(ssql, accessconn)
            Dim org, status As Integer
            Dim dr As DataRow
                ora.Fill(ds, "Table1")
endTime=Datetime.Now

diff=CInt(DateDiff(DateInterval.Minute, startTime, endTime))
0
 
LVL 35

Expert Comment

by:YZlat
ID: 18782495
or to get time in seconds, use

diff=CInt(DateDiff(DateInterval.Second, startTime, endTime))
0
 

Author Comment

by:tentavarious
ID: 18782585
Yeah, that's not what I need, if I have the time after its already completed it does me no good.  I need to calculate how long it would take before hand, that way I can show a percentage of how much time is left before its completed.  Kinda like when your downloading something, how does it it know how long it will take before its completed the download?  That is what I am looking for.
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 35

Assisted Solution

by:YZlat
YZlat earned 50 total points
ID: 18782813
I don't htink you can do that. You cannot find out how long something will take before it even started. You never know, the database might be slow one day so you cannot really predict anything
0
 
LVL 17

Expert Comment

by:ZeonFlash
ID: 18782858
I agree with YZlat:  it's nearly impossible to tell how long it's going to take to do operations on the database.  You could benchmark the operation a couple times and take the average time as your base, but it won't necessarily be accurate.  As YZlat stated, the database could be slow that day, or it could be that the database was slow the day you did the benchmarks.  Either way, it'd be hit-and-miss.

When downloading a file, it's fairly easy to determine the time left because you know how much of the file is left to download and what speed it's coming down at.  When querying a database, you could return 0 records or 1 million records....the number of which you don't know until you've actually received the records from the database.
0
 
LVL 34

Accepted Solution

by:
Sancler earned 200 total points
ID: 18783781
Here's a recent PAQ

http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_22458971.html?cid=236#a18760478

Doing it the way described in the Accepted Answer slows things down.  But there is mention, earlier in the thread, of an alternative approach - using the .Fill method with startRecord and batchSize set.

Roger
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now