Reputation: 61
I'm working in Visual Studios 2017 and I need to get the column names of a datatable named "Question
" , from a database named "qst
". Is there any way, or command that can get me the column name and then insert it in richTextBox1
?
Upvotes: 1
Views: 52
Reputation: 3906
As variant you can use the following query to get all column names for a table
SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME='YourTableName'
ORDER BY ORDINAL_POSITION
If it's necessary all table names you can get from INFORMATION_SCHEMA.TABLES
SELECT *
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE='BASE TABLE'
Upvotes: 2