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
Solved

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

Posted on 2007-03-23
6
391 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
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.

 
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Suggested Solutions

Title # Comments Views Activity
VB: Convert 2 dates to specific format 24 52
location of a form 2 25
Generate Numbers in JQuery file 11 66
ASP.NET (VB) return a record 2 37
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

839 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