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. updating many records in the Table

updating many records in the Table

Scheduled Pinned Locked Moved Database
csharpdatabasehelptutorialquestion
3 Posts 2 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.
  • M Offline
    M Offline
    minkinin
    wrote on last edited by
    #1

    pls guys help,how can I update more than one record in the table,actually I need to update dates,adding 12 months to the dates. eg. data from DB date approved expiry date 2005/05/12 2005/11/12 2005/05/28 2005/11/28 2005/06/28 2005/12/28 so how to I add 12 months to the date approved so as to get the expiry date extended with 12 months. getting something like this: latest data expiry date 2005/05/12 2006/05/12 2005/05/28 2006/05/28 2005/06/28 2006/06/28 pls guys pls I need a C# code to do that.;P

    C 1 Reply Last reply
    0
    • M minkinin

      pls guys help,how can I update more than one record in the table,actually I need to update dates,adding 12 months to the dates. eg. data from DB date approved expiry date 2005/05/12 2005/11/12 2005/05/28 2005/11/28 2005/06/28 2005/12/28 so how to I add 12 months to the date approved so as to get the expiry date extended with 12 months. getting something like this: latest data expiry date 2005/05/12 2006/05/12 2005/05/28 2006/05/28 2005/06/28 2006/06/28 pls guys pls I need a C# code to do that.;P

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      minkinin wrote:

      pls guys pls I need a C# code to do that

      C# code does not alter the database, the best it can do is to forward some SQL code to the database. You need SQL code to solve your problem. The SQL you need is something like this:

      UPDATE MyTable SET [expiry date] = dateadd(year, [latest date]);

      ColinMackay.net "Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius "If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell

      M 1 Reply Last reply
      0
      • C Colin Angus Mackay

        minkinin wrote:

        pls guys pls I need a C# code to do that

        C# code does not alter the database, the best it can do is to forward some SQL code to the database. You need SQL code to solve your problem. The SQL you need is something like this:

        UPDATE MyTable SET [expiry date] = dateadd(year, [latest date]);

        ColinMackay.net "Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius "If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell

        M Offline
        M Offline
        minkinin
        wrote on last edited by
        #3

        Thanks a lot Colin,this is exactly what I wanted and is working perfect;P

        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