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. Sort GetChildRow datarow array

Sort GetChildRow datarow array

Scheduled Pinned Locked Moved Database
databasedata-structureshelpquestion
4 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.
  • B Offline
    B Offline
    BobW999
    wrote on last edited by
    #1

    I just discovered what is a big problem with the order that child rows are retrieved from datatables created from a SQLCe database. Definition

    'Front Inner Camber Link
    Dim arrFrInnerCamb() As RCCarV2DataSet.FrInnerCambRow
    Dim FrInnerCambRow As DataRow

    The child rows are retrieved and stored in an array of DataRows.

    'Get the array of alternate Inner Camber Positions
    arrFrInnerCamb = FrSuspRow.GetChildRows("FrSuspension_FrInnerCamb")

    The problem is the order the values are stored in the Sql database are not always stored in the order of the primary key as I expect. This problem only occurs after deleting rows from the database. To correct this problem I would like to just sort the arrFrInnerCamb by the primary key and all will be good. Unfortunately can't figure out a simple way to do this. I can use a brute force and ignorance method but figure there must be an easier way. Any suggestions would be appreciated.

    M 1 Reply Last reply
    0
    • B BobW999

      I just discovered what is a big problem with the order that child rows are retrieved from datatables created from a SQLCe database. Definition

      'Front Inner Camber Link
      Dim arrFrInnerCamb() As RCCarV2DataSet.FrInnerCambRow
      Dim FrInnerCambRow As DataRow

      The child rows are retrieved and stored in an array of DataRows.

      'Get the array of alternate Inner Camber Positions
      arrFrInnerCamb = FrSuspRow.GetChildRows("FrSuspension_FrInnerCamb")

      The problem is the order the values are stored in the Sql database are not always stored in the order of the primary key as I expect. This problem only occurs after deleting rows from the database. To correct this problem I would like to just sort the arrFrInnerCamb by the primary key and all will be good. Unfortunately can't figure out a simple way to do this. I can use a brute force and ignorance method but figure there must be an easier way. Any suggestions would be appreciated.

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

      Try storing the child rows in a DataTable, you will then have all the manipulating capabilities inherent in the datatable and sorting will be simple.

      Never underestimate the power of human stupidity RAH

      B 1 Reply Last reply
      0
      • M Mycroft Holmes

        Try storing the child rows in a DataTable, you will then have all the manipulating capabilities inherent in the datatable and sorting will be simple.

        Never underestimate the power of human stupidity RAH

        B Offline
        B Offline
        BobW999
        wrote on last edited by
        #3

        Thanks I'm trying that. I was just hoping for an easy way to sort the DataRow Array so I don't have to do a major program restructure.

        M 1 Reply Last reply
        0
        • B BobW999

          Thanks I'm trying that. I was just hoping for an easy way to sort the DataRow Array so I don't have to do a major program restructure.

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

          Using the array of datarows is wrong, so you will benefit from the refactor :) You could sort the datarows BEFORE you load them into the array!

          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