Results 1 to 3 of 3

Thread: MySQL column names extraction

  1. #1
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default MySQL column names extraction

    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:

    Qt Code:
    1. CBrowserWindow::CBrowserWindow(QWidget *parent, QSqlDatabase* pDataBase, QString sTableName) : QWidget(parent)
    To copy to clipboard, switch view to plain text mode 

    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
    Qt 5.3 Opensource & Creator 3.1.2

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: MySQL column names extraction

    Use QSqlRecord. It allows you to query for field names. You can get a record object by using QSqlDatabase::record or QSqlTableModel::record.

  3. The following user says thank you to wysota for this useful post:

    MarkoSan (12th October 2007)

  4. #3
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: MySQL column names extraction

    Will try now ...
    Qt 5.3 Opensource & Creator 3.1.2

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.