Adagio
8 years agoFrequent Contributor
how to get DB table into a 2D array
Hi, I'm trying to fetch the contnts of a DB table into an array then iterating over the array to read the elements.
the DB table has 10 rows and 4 columns, but in the code below:
elementList[0,0] and elementList[1,0] are fetching the same value.
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);
In short all the value appear in a string separated by ','. I need to parse it to a table structure. How can I get these values in an array so that I can fetch each value using row column indexes?
any help would be greatly appreciated!
Thank you
Abhi