title: Get column name from SQL Server
body: <p>I'm trying to get the column names of a table I have stored in SQL Server 2008 R2.</p>
  
  <p>I've literally tried everything but I can't seem to find how to do this.</p>
  
  <p>Right now this is my code in C#</p>
  
  <pre><code>public string[] getColumnsName()
  {
          List&lt;string&gt; listacolumnas=new List&lt;string&gt;();
  
          using (SqlConnection connection = new SqlConnection(Connection))
          using (SqlCommand command = connection.CreateCommand())
          {
              command.CommandText = "SELECT TOP 0 * FROM Usuarios";
              connection.Open();
  
              using (var reader = command.ExecuteReader(CommandBehavior.KeyInfo))
              {
                  reader.Read();
  
                  var table = reader.GetSchemaTable();
  
                  foreach (DataColumn column in table.Columns)
                  {
                      listacolumnas.Add(column.ColumnName);
                  }
              }
          }
          return listacolumnas.ToArray();
      }
  </code></pre>
  
  <p>But this is returning me the following</p>
  
  <pre><code>&lt;string&gt;ColumnName&lt;/string&gt;
  &lt;string&gt;ColumnOrdinal&lt;/string&gt;
  &lt;string&gt;ColumnSize&lt;/string&gt;
  &lt;string&gt;NumericPrecision&lt;/string&gt;
  &lt;string&gt;NumericScale&lt;/string&gt;
  &lt;string&gt;IsUnique&lt;/string&gt;
  &lt;string&gt;IsKey&lt;/string&gt;
  &lt;string&gt;BaseServerName&lt;/string&gt;
  &lt;string&gt;BaseCatalogName&lt;/string&gt;
  &lt;string&gt;BaseColumnName&lt;/string&gt;
  &lt;string&gt;BaseSchemaName&lt;/string&gt;
  &lt;string&gt;BaseTableName&lt;/string&gt;
  &lt;string&gt;DataType&lt;/string&gt;
  &lt;string&gt;AllowDBNull&lt;/string&gt;
  &lt;string&gt;ProviderType&lt;/string&gt;
  &lt;string&gt;IsAliased&lt;/string&gt;
  &lt;string&gt;IsExpression&lt;/string&gt;
  &lt;string&gt;IsIdentity&lt;/string&gt;
  &lt;string&gt;IsAutoIncrement&lt;/string&gt;
  &lt;string&gt;IsRowVersion&lt;/string&gt;
  &lt;string&gt;IsHidden&lt;/string&gt;
  &lt;string&gt;IsLong&lt;/string&gt;
  &lt;string&gt;IsReadOnly&lt;/string&gt;
  &lt;string&gt;ProviderSpecificDataType&lt;/string&gt;
  &lt;string&gt;DataTypeName&lt;/string&gt;
  &lt;string&gt;XmlSchemaCollectionDatabase&lt;/string&gt;
  &lt;string&gt;XmlSchemaCollectionOwningSchema&lt;/string&gt;
  &lt;string&gt;XmlSchemaCollectionName&lt;/string&gt;
  &lt;string&gt;UdtAssemblyQualifiedName&lt;/string&gt;
  &lt;string&gt;NonVersionedProviderType&lt;/string&gt;
  &lt;string&gt;IsColumnSet&lt;/string&gt;
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p>It shows the <code>&lt;string&gt;</code> tags as this is how my web service sends the data.</p>