Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to add data to multiple tables in sqlite in c++?



  • I am getting error by using this code
    "No query unable to fetch row"

    I am trying to insert the data to two tables but 'qry2' is getting that error. I am using this to insert data, is this right?

    
           QSqlQuery qry;
           QSqlQuery qry2;
           qry.prepare("INSERT INTO first(Source,Medium,Subject,'Date & Time received document','Date & Time RRO forwarded to HOO','ControlNo.') values('"+src+"','"+med+"','"+key+"','"+one+"','"+one+"','"+res+"')");
           qry2.prepare("INSERT INTO second(Source,Medium,Subject,'Date & Time received document','Date & Time RRO forwarded to HOO','ControlNo.') values('"+src+"','"+med+"','"+key+"','"+one+"','"+one+"','"+res+"')");
    

    Yes I am inserting the same data to both tables. Can you help me?


  • Qt Champions 2019

    @ioanna Please show the whole code not only query preparation but also execution.
    Also, what does prepare() return?



  • This post is deleted!


  • @jsulm sir thank you. I found my mistake. God Bless!


Log in to reply