Click here to Skip to main content
15,887,464 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to get column names of a table in ODBC oe OLE DB programatically.
Which functions or methods should I use?
Posted
Comments
fjdiewornncalwe 9-Dec-10 7:18am    
What type of data source are you trying to get this information for? (i.e. SQL Server, Oracle, Excel, Access?)

Try this.., This may help you..

After you getting the DataTable using oledb connection.

use this

DataTable dt = new DataTable();
            dt.Columns[0].ColumnName() 
 
Share this answer
 
Comments
Rajesh Anuhya 9-Dec-10 7:27am    
Why it's downvoted???, leave a comment while you are downvoting...
fjdiewornncalwe 9-Dec-10 8:17am    
I'll counter... I like your answer a whole lot better than the SQL one above.
SELECT COLUMN_NAME  FROM INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'tablename'
 
Share this answer
 
Comments
fjdiewornncalwe 9-Dec-10 8:18am    
You're not taking into account that his datasource could be Excel or something like that.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900