title: how can I fill a data table variable value from class response in c#
body: <p>How can I pass retrieve class variable value to the <code>checkIn</code> form?</p>
  <p>checkIn form: my question is: why is the <code>oldCheckInDt</code> variable still empty?</p>
  <pre><code>// assign variable 
  DataTable oldCheckInDt = new DataTable();
  
  private void btnUpdateCheckIn_Click(object sender, EventArgs e)
  {
      Retrieve.loadDataTable(&quot;sp_loadBasicCheckIn&quot;, oldCheckInDt, Convert.ToInt32(txtCheckInId.Text.Trim()));
  
      // my question - why is &quot;oldCheckInDt&quot;// still empty
  }
  </code></pre>
  <p>Retrieve class:</p>
  <pre><code>public static void loadDataTable(string proc, DataTable tb, Int32 Id)
  {
      try
      {
          SqlCommand cmd = new SqlCommand(proc, MainClass.con);
          cmd.CommandType = CommandType.StoredProcedure;
          cmd.Parameters.AddWithValue(&quot;@id&quot;, Id);
  
          SqlDataAdapter da = new SqlDataAdapter(cmd);
  
          DataTable dt = new DataTable();
          da.Fill(dt);
  
          if (dt.Rows.Count &gt; 0)
          {
              tb = dt;    // tb successfully filled with data.
          }
          else
          {
              tb = null;
          }
      }
      catch (Exception ex)
      {
          MainClass.showMessage(&quot;Exception : &quot; + ex, &quot;error&quot;);
      }
  }
  </code></pre>