Results 1 to 3 of 3

Thread: MySQL column names extraction

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

    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,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    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
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanks
    111
    Thanked 4 Times in 4 Posts

    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
  •  
Qt is a trademark of The Qt Company.