using System.Data.SqlClient; using (SqlConnection connection = new SqlConnection("connectionString")) { connection.Open(); SqlCommand command = new SqlCommand("SELECT * FROM myTable", connection); SqlDataReader reader = command.ExecuteReader(); for (int i = 0; i < reader.FieldCount; i++) { Console.WriteLine(reader.GetName(i)); } }In this example, we first create a SqlConnection to a SQL Server database using a connection string. We then create a SqlCommand object to execute a SELECT statement against a table named "myTable". We create a SqlDataReader object from the command and iterate over the column names using the GetName method. This method is part of the System.Data.SqlClient namespace.