Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Over Write

Over Write

Scheduled Pinned Locked Moved Database
questionc++databasesqliteannouncement
3 Posts 3 Posters 0 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.
  • T Offline
    T Offline
    T RATHA KRISHNAN
    wrote on last edited by
    #1

    Hi! I'm updating a Table. Each time I update, a new record is created. But I want only one record to be created(I've to over write the existing record). My query is:

    char query[512];
    sprintf_s(query, 512, "UPDATE Current SET TeamID=(%d),Theme=(%d)", TeamSlectLst->getSelected(),ThemeSelectLst->getSelected()+1);
    SQLdb.Query(query);

    I'm using SQLite. I'm calling SQLite Query from C++. What modifications has to be done in the above Query? This may be a silly question. But don't neglect this, why because I mainly working with C++.

    B 1 Reply Last reply
    0
    • T T RATHA KRISHNAN

      Hi! I'm updating a Table. Each time I update, a new record is created. But I want only one record to be created(I've to over write the existing record). My query is:

      char query[512];
      sprintf_s(query, 512, "UPDATE Current SET TeamID=(%d),Theme=(%d)", TeamSlectLst->getSelected(),ThemeSelectLst->getSelected()+1);
      SQLdb.Query(query);

      I'm using SQLite. I'm calling SQLite Query from C++. What modifications has to be done in the above Query? This may be a silly question. But don't neglect this, why because I mainly working with C++.

      B Offline
      B Offline
      Bernhard Hiller
      wrote on last edited by
      #2

      There seem to be several issues. Current is a reserved key word for SQL Server (see http://msdn.microsoft.com/en-us/library/aa238507(SQL.80).aspx[^]). Furthermore, a WHERE clause is appropriate as otherwise all rows would receive the new values.

      UPDATE [MyTable] SET TeamID=21, Theme=59 WHERE Identifier=95

      By the way, parameterized queries are to be preferred to plain text queries.

      M 1 Reply Last reply
      0
      • B Bernhard Hiller

        There seem to be several issues. Current is a reserved key word for SQL Server (see http://msdn.microsoft.com/en-us/library/aa238507(SQL.80).aspx[^]). Furthermore, a WHERE clause is appropriate as otherwise all rows would receive the new values.

        UPDATE [MyTable] SET TeamID=21, Theme=59 WHERE Identifier=95

        By the way, parameterized queries are to be preferred to plain text queries.

        M Offline
        M Offline
        Mycroft Holmes
        wrote on last edited by
        #3

        I am pretty sure SQLite is not a SQL server product. Which probably accounts for the lack of response!

        Never underestimate the power of human stupidity RAH

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups