DataTable dtColumnNames = new DataTable();
SqlCommand command = new SqlCommand();
SqlConnection connection = GetConnection();
string commandText = "SELECT name FROM sys.syscolumns WHERE (id = OBJECT_ID(@Table))";
command.Connection = connection;
command.CommandText = commandText;
command.Parameters.Add(new SqlParameter("@Table", tableName));
SqlDataAdapter adapter = new SqlDataAdapter(command);
adapter.Fill(dtColumnNames);
zaterdag 3 oktober 2009
Get column names from a SQL table
Abonneren op:
Reacties posten (Atom)
Geen opmerkingen:
Een reactie posten