Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Error While Using SQLite
Qt 6.11 is out! See what's new in the release blog

Error While Using SQLite

Scheduled Pinned Locked Moved Installation and Deployment
4 Posts 2 Posters 4.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    khalidmushtaq65
    wrote on last edited by
    #1

    Hi,

    I am new to QT and finding problems while connecting it to SQLite. I hope you will help me in solving this..

    I am using following settings to connect.. I have created library.db using NAVICAT.

    @
    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName("C:\sqlite\library.db");
    if (!db.open()) {
    QMessageBox::critical(0, QObject::tr("Database Error"),
    db.lastError().text());
    return false;
    }
    return true;
    @

    These errors are shown while compiling..

    debug/mainwindow.o:F:\Projects\qt\DownloadAll-build-desktop/../DownloadAll/mainwindow.cpp:16: undefined reference to _imp___ZN12QSqlDatabase17defaultConnectionE' debug/mainwindow.o:F:\Projects\qt\DownloadAll-build-desktop/../DownloadAll/mainwindow.cpp:16: undefined reference to imp___ZN12QSqlDatabase11addDatabaseERK7QStringS2'
    debug/mainwindow.o:F:\Projects\qt\DownloadAll-build-desktop/../DownloadAll/mainwindow.cpp:16: undefined reference to _imp___ZN12QSqlDatabaseD1Ev' debug/mainwindow.o:F:\Projects\qt\DownloadAll-build-desktop/../DownloadAll/mainwindow.cpp:17: undefined reference to _imp___ZN12QSqlDatabase15setDatabaseNameERK7QString'
    debug/mainwindow.o:F:\Projects\qt\DownloadAll-build-desktop/../DownloadAll/mainwindow.cpp:18: undefined reference to _imp___ZN12QSqlDatabase4openEv' debug/mainwindow.o:F:\Projects\qt\DownloadAll-build-desktop/../DownloadAll/mainwindow.cpp:20: undefined reference to _imp___ZNK12QSqlDatabase9lastErrorEv'
    debug/mainwindow.o:F:\Projects\qt\DownloadAll-build-desktop/../DownloadAll/mainwindow.cpp:20: undefined reference to _imp___ZNK9QSqlError4textEv' debug/mainwindow.o:F:\Projects\qt\DownloadAll-build-desktop/../DownloadAll/mainwindow.cpp:20: undefined reference to _imp___ZN9QSqlErrorD1Ev'
    debug/mainwindow.o:F:\Projects\qt\DownloadAll-build-desktop/../DownloadAll/mainwindow.cpp:20: undefined reference to _imp___ZN9QSqlErrorD1Ev' debug/mainwindow.o:F:\Projects\qt\DownloadAll-build-desktop/../DownloadAll/mainwindow.cpp:23: undefined reference to _imp___ZN12QSqlDatabaseD1Ev'
    debug/mainwindow.o:F:\Projects\qt\DownloadAll-build-desktop/../DownloadAll/mainwindow.cpp:23: undefined reference to `_imp___ZN12QSqlDatabaseD1Ev'

    [EDIT: code formatting, please wrap in @-tags, Volker]

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      Add this to your project file:

      @
      QT += sql
      @

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • K Offline
        K Offline
        khalidmushtaq65
        wrote on last edited by
        #3

        Thanks Voker. It's working fine now:-)

        I have one more question..

        If I encrypt this database, how can I use it in QT? means what will the way to decrypt it and performing operations on the data.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          [quote author="khalidmushtaq65" date="1299184561"]
          If I encrypt this database, how can I use it in QT? means what will the way to decrypt it and performing operations on the data.
          [/quote]

          Not without additional libraries. The built-in SQLite version cannot handle encrypted databases.

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved