Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. SQLITE SELECT QUERY NOT PROPER WORKING IN QT4.8.6
Forum Updated to NodeBB v4.3 + New Features

SQLITE SELECT QUERY NOT PROPER WORKING IN QT4.8.6

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 1.2k Views 2 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.
  • M Offline
    M Offline
    Meena Solanki
    wrote on 26 Mar 2016, 05:25 last edited by
    #1

    Hii

    I am working on qt4.8.6 with Linux os and I have issue with SQLite (version 3) "select" query.
    The select query is working proper with large data on SQLite manger Tool but not in qt 4.8.6.

    Is there any dependency of using SQLite3 database with qt4.8.6 ?

    Here is my code snippet:

    QSqlQuery * query = DatabaseConnection::instance()->newSqlQuery();
    query->clear();
    query->prepare("SELECT File_ID FROM Test WHERE File_Path = :filepath AND File_Name = :filename;");
    query->bindValue(":filepath", "Test1/");
    query->bindValue(":filename", "test.txt");
    
    if( ! query->exec()){
    
        qDebug()<< "Error in sqlite query exection "<< query->lastError();
    }
    qDebug()<<"query.isActive"<<query->isActive();
    qDebug()<<"query.isSelect"<<query->isSelect();
    
    //if(query->first()){
    if(query->next()){
        fileId = query->value(0).toInt(); // I am not able to reach here.........
    }
    else
    {
     qDebug()<<" NOT In next "<<query->size(); // Right now I am here.....
    }
    
    qDebug() << "fileId "<< fileId;
    
    delete query;
    query = 0;
    

    // Where "DatabaseConnection" is my own Database class, used to create and delete the table.

    My "Create table statement" is Like:
    CREATE TABLE IF NOT EXISTS Test (File_Id INTEGER PRIMARY KEY NOT NULL,User_Id INTEGER,Updated_By INTEGER, File_Name TEXT,File_Size INTEGER,File_Type TEXT,File_Path TEXT,Is_Deleted INTEGER, Level INTEGER,Parent_Id INTEGER,Uploaded_On DATETIME ,Updated_On DATETIME,Is_Shared INTEGER, File_Input_Name TEXT);

    // See I have problem with only large database about 1000 records in db but it works fine with small data of around 50 records.

    Is there any Solution of this problem?

    Thanks

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 26 Mar 2016, 21:56 last edited by
      #2

      Hi and welcome to devnet,

      Yes there's a dependency. The SQLite plugin uses either the bundled SQLite library or the one from your system when built.

      What exact error are you getting ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Meena Solanki
        wrote on 29 Mar 2016, 04:48 last edited by
        #3

        Thanks for your reply.

        I am not getting any error while running select query, actually the output of this query is not right.

        When running the select query in SQlite manager tool the fileId is correct but Why getting fileId = 0, when I run same select query into my Application via QT creator 4.8.6 ?

        Is there any problem with large database in QT4.8.6 ?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 29 Mar 2016, 20:34 last edited by
          #4

          Can you show the code where you call that query ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          1/4

          26 Mar 2016, 05:25

          • Login

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