Zeb Rehman

Zeb Rehman

  • NA
  • 41
  • 72.8k

Progress Bar

Dec 10 2011 6:56 AM
I want to insert a progress bar so that while reader don't complete reading data from database it progress toword it's completion. The code is given following



using System;
using System.Collections.Generic;
using System.Data.OleDb;
using System.IO;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ETL_Tool
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

        try
            {
                string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;data source=D:\\ptcl_1.accdb";

                OleDbConnection conn = new OleDbConnection(connectionString);
                string sql = "SELECT * FROM 51";
                OleDbCommand cmd = new OleDbCommand(sql, conn);
                conn.Open();
                TextWriter tw = new StreamWriter("D:\\data.txt");
                OleDbDataReader reader;
                reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                        //Some operation is performed here
                }
         }

        catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

        }
    }
}

Answers (2)