title: C# WPF Create Loading Progress Bar linked to Collected results from Database
body: <p>I am Developing C# WPF Simple application. This application consists of several frames to load depending on the database. 
  For each table, I have one <code>Frame</code> and all are linked to the main page just for navigation. I created Loading frame which consists of a simple progress bar. </p>
  
  <p>That was the introduction now here is my question.</p>
  
  <p>I want to link the <code>ProgressBar</code> with collecting results from the database.
  For example this order: <code>Select * from Tablename</code>
  I want the <code>ProgressBar</code> to launch, while the results are collected.
  I am using Query on my database here is my method:
  this on my DataAccessLayer:</p>
  
  <pre><code>public static DataTable ExecuteTable(string query, CommandType type, params SqlParameter[] arr)
          {
              SqlConnection cn = new SqlConnection(con);
              cn.Open(); // connection
              SqlCommand cmd = new SqlCommand(query, cn);
              cmd.CommandType = type;
              cmd.Parameters.AddRange(arr);
              SqlDataAdapter da = new SqlDataAdapter(cmd);
              DataTable dt = new DataTable();
              da.Fill(dt);
              return dt;
          }
  </code></pre>
  
  <p>this one on my Form</p>
  
  <pre><code>public static DataTable SP_SELECTALLCATEGORIES()
          {
              DataAccessLayer.Open();
              DataTable dt = DataAccessLayer.ExecuteTable("SP_SELECTALLCATEGORIES", CommandType.StoredProcedure);
              DataAccessLayer.Close();
              return dt;
          }
  </code></pre>
  
  <p>If my table consists of 1,000,000 records I want loading <code>ProgressBar</code> linked to the loaded state for example when application loading 500,000 the <code>ProgressBar</code> should be at 50%.</p>
  
  <p>I think the reason because when we refer the data grid or binding to an element we only execute the SQL statement and it returns with the results so can we know how much of this result is loaded? thanks</p>