Solved

Progress Bar on Moving Table Data

Posted on 2009-07-06
2
629 Views
Last Modified: 2012-05-07
I try to include a progress bar while moving data from one server table to another table in another server. So i had the following code testing out,


wondering if / will the progress bar being execute based on the completion of data transfer where i put within the code bolded?  ??

string query  = ...;

string conn = ...;

string conn2 = ...;

static int recordcount = 0;

SqlDataReader reader;
 

this.pbar1 = new System.Winforms.ProgressBar();

pbar1.Visible = true;

pbar1.Maximum = recordcount;

pbar1.Minimum = 1;

pbar1.Value = 1;

pbar1.Step = 1;
 

using (reader = new SqlCommand(query, conn).ExecuteReader())

{

          if (reader.HasRows)

          {

                 recordcount = reader.Count;    
 

                 while (reader.Read())

                 {

                        string id = reader.GetString(reader.GetOrdinal("SalesID"));

                        ..
 

                        using (SqlConnection con = new SqlConnection(conn2))

                        {

                                 con.Open();

                                 try

                                 {

                                        using (SqlCommand command = new SqlCommand("INSERT INTO saletable VALUES(@saleid, @saletotal , @saledatetime)", con))

                                        {

                                                  command.Parameters.Add(new SqlParameter("saleid", id));

                                                  ...

                                        command.ExecuteNonQuery();

                                        pbar1.performStep();

                                        }

                                  }

                                  catch

                                  {

                                  }
 

                         }

                        

}

Open in new window

0
Comment
Question by:doramail05
2 Comments
 
LVL 12

Accepted Solution

by:
ShazbotOK earned 500 total points
ID: 24787407
To accuratly set the progress bar you need to 1st set the max value on the progress bar... so when you perform the reader.Count set that to the progress bar so it knows what is considered 100%
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 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

24 Experts available now in Live!

Get 1:1 Help Now