Someone might find this helpful:
System.Data.DataTable schema = null; using (System.Data.SqlClient.SqlCommand cmd = database.Connection.CreateCommand()) { cmd.CommandText = string.Format( "SELECT TOP 1 * FROM {0}", mainTable ); cmd.CommandType = System.Data.CommandType.Text; using (System.Data.SqlClient.SqlDataReader rdr = cmd.ExecuteReader()) { schema = rdr.GetSchemaTable(); } }
Graham bull
source share