You are using parameter CommandBehavior.SchemaOnly, so I think its not a problem in performance.
urtrivedi
Nearly a Posting Virtuoso
1,306 posts since Dec 2008
Reputation Points: 257
Solved Threads: 270
Basically do this (crude, but effective). Am sure you can do the rest.
public void print(bool tableData)
{
SqlConnection conn = new SqlConnection("server=SHELI-PC\\SQLEXPRESS;database=Tables;integrated security=SSPI");
SqlCommand command = conn.CreateCommand();
command.CommandText = "SELECT * FROM " + tableName;
conn.Open();
if (tableData)
{
// Table Data
}
else
{
// Column Headers
}
Console.WriteLine("");
reader.Close();
conn.Close();
}
pritaeas
Posting Expert
5,475 posts since Jul 2006
Reputation Points: 653
Solved Threads: 874
You pass false as your function parameter: print(false); If you pass true it will print the table data.
pritaeas
Posting Expert
5,475 posts since Jul 2006
Reputation Points: 653
Solved Threads: 874