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