I\'m trying to get the column names of a table I have stored in SQL Server 2008 R2.
I\'ve literally tried everything but I can\'t seem to find how to do this.
Ri
I typically use the GetSchema method to retrieve Column specific information, this snippet will return the column names in a string List:
using (SqlConnection conn = new SqlConnection(""))
{
string[] restrictions = new string[4] { null, null, "", null };
conn.Open();
var columnList = conn.GetSchema("Columns", restrictions).AsEnumerable().Select(s => s.Field("Column_Name")).ToList();
}