In c# (or ADO.NET) is there a way to get all the column names of a given database table
I have an application written in c# that inserts rows into a database. Everyday when the application is started it connects to the DB and then gets a list of all columns in the database. I do this to make sure all the necessary columns are in the DB.
Currently I create an OdbcCommand object and issue the following query SELECT * FROM table WHERE 1 = 2. Then I iterate through the OdbcDataReader that is returned to get a list of all column names. The problem is that one of the DB I connect to has more then 18 million rows and the DB query optimizer is throwing out my query because it says it will time out on an 18 million row table span.
Is there a better way to get the column names? The application connects to DB2, Oracle and SQL server databases