Solved

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

Posted on 2007-03-23
6
390 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

776 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