Solved

Progress Bar on Moving Table Data

Posted on 2009-07-06
2
632 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

820 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