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. Sqlite and Qt issue, need guidance
Forum Updated to NodeBB v4.3 + New Features

Sqlite and Qt issue, need guidance

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 895 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.
  • S Offline
    S Offline
    sw23
    wrote on last edited by A Former User
    #1

    Hello, I'm looking for some advice on sqlite- I have very little experience with databases.

    I'll start by explaining what I am trying to accomplish. Each entry I have in my database has a total of 12 fields. When I originally submit the entry everything goes great.

    My problem arises from a new function which I use to update specific fields while retaining all the prior information in the other fields that are not being updated.

    This is a small example-- my primary key is the partID followed by partType, partLocation, partAge, etc... I'll keep it 4 fields long for simplicity in this example.

    let's say I already have information in this entry such as

    partID = 123, partType = blade, partLocation = shelf2, partAge = 2 months

    Now for this entry I want to change partLocation from its original location of shelf2 to shelf3- while retaining the data in the other fields that are not changing.

    Here is what I have so far...

    qry.prepare("INSERT OR REPLACE INTO partInformation WHERE partID='"+partNumber+"' (partID,partType,partLocation,partAge) VALUES (:partID,:partType,:partLocation,:partAge)");

    qry.bindValue(":partID", pID); // I don't wish to update this field
    qry.bindValue(":partType", pType); // I don't wish to update this field

    qry.bindValue(":partLocation", pLoc); //This I want to update only

    qry.bindValue(":partAge", pAge);// I dont wish to update this field

    I have been looking for a way to tell it to ignore the unwanted ones, I don't even know if that is possible.

    If I don't include the unwanted bind values I get a parameter count mismatch error.

    Can someone please guide me in the right direction? I appreciate it

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Why not use the UPDATE statement then ?
      https://www.w3schools.com/sql/sql_update.asp

      1 Reply Last reply
      1
      • S Offline
        S Offline
        sw23
        wrote on last edited by sw23
        #3

        That solved my issue, thank you for the help

        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