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. How to add data to multiple tables in sqlite in c++?

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 374 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.
  • I Offline
    I Offline
    ioanna
    wrote on 10 Mar 2020, 07:43 last edited by ioanna 3 Oct 2020, 07:45
    #1

    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?

    J 1 Reply Last reply 10 Mar 2020, 08:21
    0
    • I ioanna
      10 Mar 2020, 07:43

      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?

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 10 Mar 2020, 08:21 last edited by
      #2

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

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      I 1 Reply Last reply 10 Mar 2020, 08:34
      0
      • I Offline
        I Offline
        ioanna
        wrote on 10 Mar 2020, 08:24 last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • J jsulm
          10 Mar 2020, 08:21

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

          I Offline
          I Offline
          ioanna
          wrote on 10 Mar 2020, 08:34 last edited by
          #4

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

          1 Reply Last reply
          0

          1/4

          10 Mar 2020, 07:43

          • 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