Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. India
  4. How to take input date from user in qdateedit and show database accordingly
Forum Update on Monday, May 27th 2025

How to take input date from user in qdateedit and show database accordingly

Scheduled Pinned Locked Moved India
22 Posts 4 Posters 15.7k Views
  • 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.
  • S Offline
    S Offline
    shreesh
    wrote on 6 Dec 2014, 08:13 last edited by
    #13

    Yes, I tried using boolean values too, problem still persists.
    Thanks for the effort.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      shreesh
      wrote on 6 Dec 2014, 08:13 last edited by
      #14

      Yes, I tried using boolean values too, problem still persists.
      Thanks for the effort.

      1 Reply Last reply
      0
      • P Offline
        P Offline
        p3c0
        Moderators
        wrote on 6 Dec 2014, 08:50 last edited by
        #15

        Can you post other parts of the code in relevance to this problem ?

        157

        1 Reply Last reply
        0
        • P Offline
          P Offline
          p3c0
          Moderators
          wrote on 6 Dec 2014, 08:50 last edited by
          #16

          Can you post other parts of the code in relevance to this problem ?

          157

          1 Reply Last reply
          0
          • S Offline
            S Offline
            shreesh
            wrote on 6 Dec 2014, 11:41 last edited by
            #17

            I am sorry for the partial code. Below is my actual code.

            @login_page conn;
            QString fill = ui->tableView->model()->data(index).toString();

            if(!conn.connopen())
            {
            qDebug()<<"Not connected";
            return;
            }

            conn.connopen();
            QSqlQuery * qry = new QSqlQuery();
            QSqlQuery * qry1 = new QSqlQuery();
            QSqlQuery * qry2 = new QSqlQuery();
            QSqlQuery * qry3 = new QSqlQuery();
            qry->prepare("select * from instructor where i_id='"+fill+"' or i_name='"+fill+"'");
            qry1->prepare("select gender from instructor where i_id='"+fill+"' or i_name='"+fill+"'");
            
            qry2->prepare("select dob from instructor where i_id='"+fill+"' or i_name='"+fill+"'");
            qry3->prepare("select yoga,martial_arts,aerobics,zumba,general,swimming,cardio,studio_cycel from instructor where i_id='"+fill+"' or i_name='"+fill+"'");
            
            
            if(qry->exec&#40;&#41; and qry1->exec(&#41; and qry2->exec(&#41; and qry3->exec(&#41;&#41;
            {
                while(qry->next(&#41; and qry1->next(&#41; and qry2->next(&#41; and qry3->exec(&#41;&#41;
                {
                  QString str = qry1->value(0&#41;.toString(&#41;;
                  //QString y,ma,a,z,g,s,sc,c;
                  QString y = qry3->value(0&#41;.toString(&#41;;
                  QString ma = qry3->value(1&#41;.toString(&#41;;
                  QString a = qry3->value(2&#41;.toString(&#41;;
                  QString z = qry3->value(3).toString();
                  QString g = qry3->value(4).toString();
                  QString s = qry3->value(5).toString();
                  QString c = qry3->value(6).toString();
                  QString sc = qry3->value(7).toString();
            
                  ui->txt_iid->setText(qry->value(0).toString());
                  ui->txt_iname->setText(qry->value(1).toString());
                  if((str == "male"))
                  {
                  ui->radioButton_male_2->setChecked(1);
                  }
                  else
                  ui->radioButton_female_2->setChecked(1);
            
                 
            
                  if(y == "Yoga")
                  {
                      ui->checkBox_yoga->setChecked(1);
                  }
                  if(ma == "Martial arts")
                  {
                      ui->checkBox_ma->setChecked(1);
                  }
                  if((a == "Aerobics"))
                  {
                      ui->checkBox_a->setChecked(1);
                  }
                  if((z == "Zumba"))
                  {
                      ui->checkBox_z->setChecked(1);
                  }
                  if((g == "General"))
                  {
                      ui->checkBox_g->setChecked(1);
                  }
                  if((s == "Swimming"))
                  {
                      ui->checkBox_s->setChecked(1);
                  }
                  if((c == "Cardio"))
                  {
                      ui->checkBox_c->setChecked(1);
                  }
                  if((sc == "Studio cycle"))
                  {
                      ui->checkBox_sc->setChecked(1);
                  }
            
                  ui->txt_phone->setText(qry->value(12).toString());
                  ui->txt_street->setText(qry->value(13).toString());
                  ui->txt_apt->setText(qry->value(14).toString());
                  ui->txt_city->setText(qry->value(15).toString());
                  ui->txt_state->setText(qry->value(16).toString());
                  ui->txt_zip->setText(qry->value(17).toString());
            
                  conn.connclose();
                }
            
            }
            else
                QMessageBox::information(this,tr("Error"),tr("Error in diaplaying")); @
            
            1 Reply Last reply
            0
            • S Offline
              S Offline
              shreesh
              wrote on 6 Dec 2014, 11:41 last edited by
              #18

              I am sorry for the partial code. Below is my actual code.

              @login_page conn;
              QString fill = ui->tableView->model()->data(index).toString();

              if(!conn.connopen())
              {
              qDebug()<<"Not connected";
              return;
              }

              conn.connopen();
              QSqlQuery * qry = new QSqlQuery();
              QSqlQuery * qry1 = new QSqlQuery();
              QSqlQuery * qry2 = new QSqlQuery();
              QSqlQuery * qry3 = new QSqlQuery();
              qry->prepare("select * from instructor where i_id='"+fill+"' or i_name='"+fill+"'");
              qry1->prepare("select gender from instructor where i_id='"+fill+"' or i_name='"+fill+"'");
              
              qry2->prepare("select dob from instructor where i_id='"+fill+"' or i_name='"+fill+"'");
              qry3->prepare("select yoga,martial_arts,aerobics,zumba,general,swimming,cardio,studio_cycel from instructor where i_id='"+fill+"' or i_name='"+fill+"'");
              
              
              if(qry->exec&#40;&#41; and qry1->exec(&#41; and qry2->exec(&#41; and qry3->exec(&#41;&#41;
              {
                  while(qry->next(&#41; and qry1->next(&#41; and qry2->next(&#41; and qry3->exec(&#41;&#41;
                  {
                    QString str = qry1->value(0&#41;.toString(&#41;;
                    //QString y,ma,a,z,g,s,sc,c;
                    QString y = qry3->value(0&#41;.toString(&#41;;
                    QString ma = qry3->value(1&#41;.toString(&#41;;
                    QString a = qry3->value(2&#41;.toString(&#41;;
                    QString z = qry3->value(3).toString();
                    QString g = qry3->value(4).toString();
                    QString s = qry3->value(5).toString();
                    QString c = qry3->value(6).toString();
                    QString sc = qry3->value(7).toString();
              
                    ui->txt_iid->setText(qry->value(0).toString());
                    ui->txt_iname->setText(qry->value(1).toString());
                    if((str == "male"))
                    {
                    ui->radioButton_male_2->setChecked(1);
                    }
                    else
                    ui->radioButton_female_2->setChecked(1);
              
                   
              
                    if(y == "Yoga")
                    {
                        ui->checkBox_yoga->setChecked(1);
                    }
                    if(ma == "Martial arts")
                    {
                        ui->checkBox_ma->setChecked(1);
                    }
                    if((a == "Aerobics"))
                    {
                        ui->checkBox_a->setChecked(1);
                    }
                    if((z == "Zumba"))
                    {
                        ui->checkBox_z->setChecked(1);
                    }
                    if((g == "General"))
                    {
                        ui->checkBox_g->setChecked(1);
                    }
                    if((s == "Swimming"))
                    {
                        ui->checkBox_s->setChecked(1);
                    }
                    if((c == "Cardio"))
                    {
                        ui->checkBox_c->setChecked(1);
                    }
                    if((sc == "Studio cycle"))
                    {
                        ui->checkBox_sc->setChecked(1);
                    }
              
                    ui->txt_phone->setText(qry->value(12).toString());
                    ui->txt_street->setText(qry->value(13).toString());
                    ui->txt_apt->setText(qry->value(14).toString());
                    ui->txt_city->setText(qry->value(15).toString());
                    ui->txt_state->setText(qry->value(16).toString());
                    ui->txt_zip->setText(qry->value(17).toString());
              
                    conn.connclose();
                  }
              
              }
              else
                  QMessageBox::information(this,tr("Error"),tr("Error in diaplaying")); @
              
              1 Reply Last reply
              0
              • P Offline
                P Offline
                p3c0
                Moderators
                wrote on 6 Dec 2014, 14:18 last edited by
                #19

                Sorry but the code looks little bit weird. I think you must first rectify them:

                1. No need to open the database twice.
                2. Since you are fetching everything from the same table with same where clauses why unnecessarily complicate the code by firing 4 different queries.
                3. Furthermore it complicates the if and while conditions.
                4. Closing the connection in while loop would be a bad idea as it will close the database and the end of first iteration itself and thus affecting the remaining data if any.

                157

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  p3c0
                  Moderators
                  wrote on 6 Dec 2014, 14:18 last edited by
                  #20

                  Sorry but the code looks little bit weird. I think you must first rectify them:

                  1. No need to open the database twice.
                  2. Since you are fetching everything from the same table with same where clauses why unnecessarily complicate the code by firing 4 different queries.
                  3. Furthermore it complicates the if and while conditions.
                  4. Closing the connection in while loop would be a bad idea as it will close the database and the end of first iteration itself and thus affecting the remaining data if any.

                  157

                  1 Reply Last reply
                  0
                  • ? This user is from outside of this forum
                    ? This user is from outside of this forum
                    Guest
                    wrote on 2 Feb 2015, 16:58 last edited by
                    #21
                    This post is deleted!
                    1 Reply Last reply
                    0
                    • ? This user is from outside of this forum
                      ? This user is from outside of this forum
                      Guest
                      wrote on 2 Feb 2015, 16:58 last edited by
                      #22
                      This post is deleted!
                      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