Results 1 to 4 of 4

Thread: I have a validation in 3 days and my projects does not work !!!! please help

  1. #1
    Join Date
    Nov 2017
    Posts
    6
    Qt products
    Qt4
    Platforms
    Windows

    Unhappy I have a validation in 3 days and my projects does not work !!!! please help

    okay so i need to simply add information to an oracle (sql) database and it loads this message and i don't understand what is the source f the problem and you see if i can't add then i can't modify or delete or anything !!!!!!!!!!!! please help !!!!!!!!!!!!!!!!


    this is the message :QODBCResult::exec: Unable to execute statement: "[Microsoft][Gestionnaire de pilotes ODBC] Erreur de séquence de la fonction"
    although it says that i'm connected to database !!!!!!!!! for any futher information about the code tell me and i will send it to you

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,640
    Thanks
    13
    Thanked 1,592 Times in 1,520 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: I have a validation in 3 days and my projects does not work !!!! please help

    The actual code including the offending SQL would be a good start.
    "We can't solve problems by using the same kind of thinking we used when we created them." -- Einstein
    If you are posting code then please use [code] [/code] tags around it - makes addressing the problem easier.

  3. #3
    Join Date
    Nov 2017
    Posts
    6
    Qt products
    Qt4
    Platforms
    Windows

    Exclamation Re: I have a validation in 3 days and my projects does not work !!!! please help

    Thank you so much for your reply so here is the function add in convention.cpp:
    Qt Code:
    1. #include "convention.h"
    2. #include "ui_convontion.h"
    3. #include"connexion.h"
    4. #include <QtSql>
    5. #include<QSqlQuery>
    6. #include"QString"
    7. #include<QtSql/QSqlDatabase>
    8. #include<QMessageBox>
    9. convention::convention(int id_c,QString nom_entreprise,int pourcentage_c,QString date_expiration)
    10.  
    11. {
    12. this->id_c=id_c;
    13. this->nom_entreprise=nom_entreprise;
    14. this->pourcentage_c=pourcentage_c;
    15. this->date_expiration=date_expiration;
    16. }
    17.  
    18. /*convention::~convention()
    19. {
    20.   delete ui;
    21. }*/
    22.  
    23. bool convention::ajouter_convention(convention *c)
    24. { //bool verif=false;
    25. QSqlQuery query;
    26.  
    27. query.prepare("INSERT INTO CONVENTIONS (id_c,nom_entreprise,pourcentage_c, date_expiration) "
    28. "VALUES (:id_c, :nom_entreprise, :pourcentage_c, :date_expiration");
    29.  
    30. //verif= query.exec();
    31.  
    32. query.bindValue(0, c->get_Id_c());
    33. query.bindValue(1,c->get_Nom_entreprise());
    34. query.bindValue(2, c->get_Pourcentage_c());
    35. query.bindValue(3, c->get_date_expiration());
    36.  
    37.  
    38. return query.exec();
    39.  
    40. //verif ;
    41.  
    42.  
    43. }
    To copy to clipboard, switch view to plain text mode 
    and this is the pushbutton code :
    Qt Code:
    1. #include "form_ajout_convontion.h"
    2. #include "ui_form_ajout_convontion.h"
    3. #include"convention.h"
    4. #include"QMessageBox"
    5. #include"ui_convontion.h"
    6. #include"connexion.h"
    7.  
    8. Form_ajout_convontion::Form_ajout_convontion(QWidget *parent) :
    9. QWidget(parent),
    10. ui(new Ui::Form_ajout_convontion)
    11. {
    12. ui->setupUi(this);
    13. }
    14.  
    15. Form_ajout_convontion::~Form_ajout_convontion()
    16. {
    17. delete ui;
    18. }
    19.  
    20. void Form_ajout_convontion::on_pushButton_clicked()
    21. {
    22.  
    23. int id_c;
    24. QString nom_entreprise;
    25. int pourcentage_c;
    26. QString date_expiration ;
    27.  
    28. id_c=ui->lineEdit->text().toInt();
    29. nom_entreprise =ui->lineEdit_2->text();
    30. pourcentage_c=ui->lineEdit_3->text().toInt();
    31. date_expiration=ui->lineEdit_4->text();
    32.  
    33. convention *c =new convention(id_c, nom_entreprise,pourcentage_c, date_expiration) ;
    34. c->ajouter_convention(c);
    35.  
    36.  
    37.  
    38. }
    To copy to clipboard, switch view to plain text mode 

    and this is the connexion.cpp code:
    Qt Code:
    1. #include "mainwindow.h"
    2. #include"connexion.h"
    3. //#include "ui_mainwindow.h"
    4. //#include <QMainWindow>
    5. #include<QDebug>
    6. //#include <QWidget>
    7. #include <QApplication>
    8. #include<QtSql/QSqlDatabase>
    9. #include<QMessageBox>
    10.  
    11.  
    12. bool Connexion::create_connection()
    13. {
    14. QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
    15. db.setDatabaseName("mybase");
    16. db.setUserName("hr");
    17. db.setPassword("26113051malek");
    18.  
    19. //return (db.open());
    20. if (!db.open()) {
    21. qDebug()<<"not connected to database";
    22. QMessageBox::critical(0, qApp->tr("Cannot open database"),
    23. qApp->tr("Unable to establish a database connection.\n"
    24. "This example needs Oracle support. Please read "
    25. "the Qt OCI driver documentation for information how "
    26. "to build it.\n\n"
    27. "Click Cancel to exit."), QMessageBox::Cancel);
    28.  
    29. return false;
    30. }
    31. else
    32. {
    33. qDebug()<<"connected to database";
    34. return true;
    35. }
    36.  
    37.  
    38.  
    39. }
    To copy to clipboard, switch view to plain text mode 
    so , no error is loaded while compiling this code but when i hit the add button this message is written and no adding to the databse happends :
    connected to database
    QODBCResult::exec: Unable to execute statement: "[Microsoft][Gestionnaire de pilotes ODBC] Erreur de séquence de la fonction"




    in the end thank you so much for any help you can give !!!

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,713
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: I have a validation in 3 days and my projects does not work !!!! please help

    Your error is an ODBC/SQL error - the sequence of operations you are doing on the query is not right.
    You probably will get more help from SQL/ODBC related forums.

    However on a C++ level one thing seems odd in your code:
    Qt Code:
    1. convention *c =new convention(id_c, nom_entreprise,pourcentage_c, date_expiration) ;
    2. c->ajouter_convention(c);
    To copy to clipboard, switch view to plain text mode 
    Why are you creating an instance of 'convention' only to give it to it self?
    Do you know what 'this' is?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Qt Developer Days SF
    By Mosaic Software in forum General Discussion
    Replies: 0
    Last Post: 7th December 2011, 21:56
  2. Replies: 2
    Last Post: 7th September 2010, 21:19
  3. General qt days..
    By Y-Less in forum Qt Programming
    Replies: 8
    Last Post: 10th April 2008, 21:41
  4. who can help me? It cost me many days.
    By diaryon0 in forum General Programming
    Replies: 1
    Last Post: 23rd April 2006, 09:48

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.