title: Get the all columns counts and storing the number in a variable
body: <p>I want to search in 3 tables in database where paname equal to text after that i used GetSchema to calculate the columns numbers in these tables to use it in for loop statement but getShema always print the 28 instead of real columns number.</p>
  <blockquote>
  <p>i have 50 columns in all these tables</p>
  </blockquote>
  <pre><code>            con.ConnectionString = @&quot;Provider=Microsoft.ACE.OLEDB.12.0;Data Source=labx.accdb&quot;;
  
              con.Open();
  
              OleDbCommand cmd = new OleDbCommand();
              cmd.Connection = con;
  
              cmd.CommandText = &quot;SELECT hema.*,bioche.*,immuni.* FROM [hema],[bioche],[immuni] WHERE hema.paname = @paname AND bioche.paname = @paname AND immuni.paname = @paname&quot;;
  
              cmd.Parameters.AddWithValue(&quot;@paname&quot;, textBox2.Text);
              OleDbDataReader dr = cmd.ExecuteReader();
  
              int cont = 0;
  
              var colCount= con.GetSchema(&quot;columns&quot;).Columns.Count; // Get the numbers of columns 
  
              MessageBox.Show(tables.ToString()); // print the count of these columns in a massageBox
  
              while (dr.Read())
              { 
                     src searchfrm = new src();
                     searchfrm.Show();
  
                     
  
                  if (cont == 0)
                  {
                      searchfrm.textBox1.Text = dr[0].ToString();
                      searchfrm.textBox2.Text = dr[1].ToString();
  
                      for (int x = 0; x &lt; 50; x++) // i want to use colCount here instead of 50
                      {
                         if (dr[x].ToString().Trim() != &quot;&quot;)searchfrm.textBox3.Text += dr[x].ToString() + System.Environment.NewLine;
  
                      }
  
                  }
  
              }
  
              con.Close();
          
          
          }
  </code></pre>