PDA

View Full Version : MySQL column names extraction



MarkoSan
12th October 2007, 10:11
Hi to all!

I want to develop a class that will act as universal browser with insert, select, change and delete records functionality. To achieve that, I somehow need to extract column names from table, which name is passed in constructor of this class:



CBrowserWindow::CBrowserWindow(QWidget *parent, QSqlDatabase* pDataBase, QString sTableName) : QWidget(parent)


Does anyone has any idea how to achieve that?

And secondly, is there in addition to extracting column names any method of extracting column's place in table (i.e., is it first column in table, second, third, ...)?

Sincerely,
Marko

wysota
12th October 2007, 11:31
Use QSqlRecord. It allows you to query for field names. You can get a record object by using QSqlDatabase::record or QSqlTableModel::record.

MarkoSan
12th October 2007, 11:51
Will try now ...