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. General Programming
  3. C / C++ / MFC
  4. Perform operations on c++ DataTable

Perform operations on c++ DataTable

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
24 Posts 6 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.
  • U User 11196121

    Please Richard a quick look at my previous post (also copied below)

    "No, it still makes no sense. You add an extra column to your table and then you say you need to store information in extra rows. Choose one or the other."

    I've added an extra ret column
    DataColumn^rt_col=gcnew DataColumn();
    rt_col->ColumnName = "Ret";
    rt_col->DataType=System::Type::GetType("System.Double");
    dbdataset->Columns->Add(rt_col);
    Then I need to fill the rows of this new column "Ret" based on the values held in "Population" column.
    1st value of "Ret" should equal = log( 1st value of Population / 2nd value of Population)
    2nd value of "Ret" = log (3rd value of Population / 4th value of Population)
    ....

    ps: please let me reiterate that both "Ret" and "Population" are columns from the datable object dbdataset.

    Cheers

    ** in vba it will take me <3 minutes to perform it but I am stuck in c++ (part of the learning process I suppose ) Again thanks for the help

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #21

    And once again, I repeat, I have already shown you how to fill these columns. You just iterate through the rows of your datatable inserting the values (however you calculate them) into the Ret column of each row.

    U 1 Reply Last reply
    0
    • L Lost User

      And once again, I repeat, I have already shown you how to fill these columns. You just iterate through the rows of your datatable inserting the values (however you calculate them) into the Ret column of each row.

      U Offline
      U Offline
      User 11196121
      wrote on last edited by
      #22

      Thanks again Richard. Could this suggestion be translated into codes for implementation? then I will surely learn from your post as this is much more concrete. cheers

      L 1 Reply Last reply
      0
      • U User 11196121

        Thanks again Richard. Could this suggestion be translated into codes for implementation? then I will surely learn from your post as this is much more concrete. cheers

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #23

        I showed you the codes at http://www.codeproject.com/Messages/4949941/Re-Perform-operations-on-cplusplus-DataTable.aspx[^]. I do not understand what more you are looking for.

        U 1 Reply Last reply
        0
        • L Lost User

          I showed you the codes at http://www.codeproject.com/Messages/4949941/Re-Perform-operations-on-cplusplus-DataTable.aspx[^]. I do not understand what more you are looking for.

          U Offline
          U Offline
          User 11196121
          wrote on last edited by
          #24

          Hi Richard, First and foremost, sincere apologies for a naivety mainly attributable to inexperience Yet. I acknowledge that the code posted is perfectly fine. While adapting to my needs, performing the loop before the below piece of code has resulted in blank "Ret" columns, confused me, and triggered some skepticism.

          sda->Fill(dbdataset);

          Now all look fine, and I'd like to thank you very much for your assistance. I spent the weekend on this mater whereas it took you barely few minutes from your side to bring a concrete solution. Hence I am indeed impressed, and hope to become a day a c++ pundit like you so as to give back by helping others on forums too.

          Cheers

          Member 11230372

          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