title: How can I count the number of tables in C#
body: <p>How can I make a code to get the number of tables to a link textbox in a given database? I'm using visual studio 2013 and  I'm new to this. I used database server  ms sql.</p>
  
  <pre><code>public static List&lt;string&gt; GetTables(string connectionString)
  {
      using (SqlConnection connection = new SqlConnection(connectionString))
      {
          connection.Open();
          DataTable schema = connection.GetSchema("Tables");
          List&lt;string&gt; TableNames = new List&lt;string&gt;();
          foreach (DataRow row in schema.Rows)
          {
            TableNames.Add(row[0].ToString());
          }
          return TableNames;
  
      }
  
  }
  </code></pre>