Re: Recordset to 2D Array Question

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Dave Methvin (news0110_at_methvin.com)
Date: 12/09/04


Date: Thu, 9 Dec 2004 10:02:11 -0500

How about something like this? I have no idea how efficient it would be for
10K rows though. Instead of toArray you could use the VBArray getItem
accessor method, that might use less memory but you'd have to test it to
find out.

function SqlQueryFieldArray(query)
{
 var rs = Conn.Execute(query);
 if ( rs.EOF ) return [ ];
 var nfields = rs.Fields.Count;
 var dbrows = rs.GetRows().toArray();
 rs.Close();
 var rows = [ ];
 for ( var d=0; d < dbrows.length; /* d++ below */ ) {
  var row = [];
  for ( var f=0; f < nfields; f++ )
    row.push(dbrows[d++]);
  rows.push(row);
 }
 return rows;
}

"violetaria" <terri.calderone@gmail.com> wrote in message
news:1102532108.568110.126460@f14g2000cwb.googlegroups.com...
I'm trying to find the fastest way to get a recordset into a 2D array
in JScript. I need to handle recordset with at least 10,000 entries in
a reasonable about of time. Currently my code looks like this:

rs1.open(sql,conn,3,3);
if (!rs1.EOF)
{
var strData = rs1.GetString(2,-1,",",";","");
var rowsArray = strData.split(";");
var finalArray = new Array();
var counter=0;
for(i=0;i<rowsArray.length;i++)
{
finalArray[counter++] = rowsArray[i].split(",");
}
rs1.close();
}

This is extremely slow and I need to find a better way to do this. I
don't think a loop with moveNext() will be any better. Does anyone
have any suggestions?
Thanks!



Relevant Pages

  • Re: TrySetLength not possible !? :(
    ... The length of the array is supposed to be the number of elements. ... function SkybuckTrySetLength(var ParaVar; const ParaNewLength: ... vWord: array of Word; ... vLongword: array of Longword; ...
    (alt.comp.lang.borland-delphi)
  • (patch for Bash) regex case statement
    ... Following up on my previous patch for regex conditional tests, ... /* Return an array of strings; ... int dollarflag, zeropad, compareflag; ... SHELL_VAR *var; ...
    (comp.unix.shell)
  • Re: Updated datestamp doesnt work
    ... Public Sub StoreOldVals ... ' store values of current row in array ... Dim n As Integer, intlast As Integer ... Dim var As Variant ...
    (microsoft.public.access.gettingstarted)
  • Re: Updated datestamp doesnt work
    ... Public Sub StoreOldVals ... ' store values of current row in array ... Dim n As Integer, intlast As Integer ... Dim var As Variant ...
    (microsoft.public.access.gettingstarted)
  • Re: Updated datestamp doesnt work
    ... Public Sub StoreOldVals ... ' store values of current row in array ... Dim n As Integer, intlast As Integer ... Dim var As Variant ...
    (microsoft.public.access.gettingstarted)