Forum Discussion
tristaanogre
8 years agoEsteemed Contributor
What if you change your code to this?
conn.Open(); var set; //execute query for a payment type set = conn.Execute_( "select XXXXXXX "); var elementList = new Array(); set.MoveFirst(); while(! set.EOF) { elementList.push([ set.Fields.Item("Col1").Value ,set.Fields.Item("Col2").Value ,set.Fields.Item("Col3").Value ,set.Fields.Item("Col4").Value] ); set.MoveNext(); } Log.Message(elementList[0][0]); Log.Message(elementList[1][0]); Log.Message(elementList);
Basically, you end up with an array of arrays which is what a 2D array is, effectively.
- Adagio8 years agoFrequent Contributor
Thank you Robert! It helps but problem is still not solved.
This time, I have one whole row of the table going in each element of the array i.e.
elementList[0][0] = FirstRow
elementList[1][0] = SecondRow
elementList[1][0] = ThirdRowand each cell of that row is separated by ',' . Still trying to get a 2d array like structure in the result.
Thank you
Abhi
- tristaanogre8 years agoEsteemed Contributor
Something is wrong in your implementation. Please make sure that you have all the code changes I included. In my tests, what I posted works as desired.
The important piece is here
elementList.push([ set.Fields.Item("Col1").Value ,set.Fields.Item("Col2").Value ,set.Fields.Item("Col3").Value ,set.Fields.Item("Col4").Value] ); set.MoveNext(); }
Note the square brackets within the "push" call. If you don't have those, you won't get the desired nested array. Please double check this.
Related Content
- 2 years ago
- 3 years ago
- 12 years ago
- 6 years ago
- 3 years ago
Recent Discussions
- 2 days ago
- 2 days ago
- 5 days ago