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. Problem with data base queries .
Forum Updated to NodeBB v4.3 + New Features

Problem with data base queries .

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 534 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.
  • Y Offline
    Y Offline
    ysing
    wrote on last edited by
    #1

    Hi this piece of code was working fine until I changed the database extension(.db instead of .sqlite) the queries don't want to execute anymore even when the data base is connected.

    Here is the function where I have the problem..

    in this particular function the output result stops in displaying " query is prepared" .

    @void home::on_pushButton_2_clicked()
    {
    QString user_name,password;

    user_name=ui->lineEdit->text();
    password=ui->lineEdit_2->text();
    if(!connOpen()){
        qDebug()<<"failed to open Data Base ";
        return;
    }
    connOpen();
    qDebug()<<("Data base is opened");
    QSqlQuery qry;
    qry.prepare("select * from description_societe where nom='"+user_name+"' and mp='"+password+"' ");
    qDebug()<<("qry is prepared");
    if(qry.exec&#40;&#41;&#41;{
        qDebug()<<("query is executing...");
        int count=0;
        while(qry.next())
        {
            count++;
        }
    
        if(count==1)
        {
           ui->label_16->setText("user_name and password are correct");
           connClose();
           qDebug()<<("connection closed");
           loginEntreprise a;
           this->hide();
           a.setModal(true);
           a.exec&#40;&#41;;
        }
        if(count>1&#41;
        {
            ui->label_16->setText("duplicate user_name or password");
        }
        if(count<1)
        {
            ui->label_16->setText("user_name or password are incorrect");
        }
    
    }
    

    }@

    Thanks in advance.

    1 Reply Last reply
    0
    • T Offline
      T Offline
      Tomme
      wrote on last edited by
      #2

      Hi,
      Find here some advices :
      First, connOpen() is called twice,
      The method prepare returns a bool... check it too,
      Use qry.LastError () for more information.
      Bye

      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