Solved

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

Posted on 2007-03-23
6
394 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

705 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