title: How to count all rows in a data table c#
body: <p>So I am creating a messaging application for a college project and I have a database of Users in Access, I have linked the database correctly and can execute statements but I am struggling with one problem, how to count the number of rows in a data table.</p>
  
  <p>In fact, all I want to do is to count the total number of users and my teacher told me to get the data into a DataTable and count the number of rows. However, no matter how many users I have in the database, it always returns as 2.</p>
  
  <pre><code>int UserCount = 0;
  
          using (OleDbConnection cuConn = new OleDbConnection())
          {
              cuConn.ConnectionString = @"DATASOURCE";
              string statement = "SELECT COUNT(*) FROM Users";
  
              OleDbDataAdapter da = new OleDbDataAdapter(statement, cuConn);
              DataTable Results = new DataTable();
              da.Fill(Results);
              if (Results.Rows.Count &gt; 0)
              {
                  UserCount = int.Parse(Results.Rows[0][0].ToString());
              }
          }
  </code></pre>
  
  <p>The above code is a copy of what I was sent by my teacher who said it would work. Any help would be appreciated.</p>
  
  <p>Also, sorry if this is a waste of time, still getting used to this StackOverflow thing...</p>