PDA

View Full Version : list tables column name (database)



baray98
19th June 2009, 07:40
I am very new to database . I use QSqlDatabase to connect to a database ( access, MySQL,SQL) , I want to get all the tables in a database and all the column names under that table.

Now, I am wondering , given QSqlDatabase and QSqlQuery , can I get the column names of each tables? I can easily get the tables list in that database thru QSqlDatabase::tables() but the columns (column names) under each table is my problem.

Please help,

baray98

ossobuco
26th September 2012, 12:18
QSqlDatabase db;
...
QSqlRecord record=db.record("mytable");

see QSqlRecord documentation for more details