Re: Recordset to 2D Array Question
From: Dave Methvin (news0110_at_methvin.com)
Date: 12/09/04
- Next message: Daniel Madura: "Re: Website js broken"
- Previous message: Woody: "Re: regular expressions..ughh"
- In reply to: violetaria: "Recordset to 2D Array Question"
- Next in thread: violetaria: "Re: Recordset to 2D Array Question"
- Reply: violetaria: "Re: Recordset to 2D Array Question"
- Messages sorted by: [ date ] [ thread ]
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!
- Next message: Daniel Madura: "Re: Website js broken"
- Previous message: Woody: "Re: regular expressions..ughh"
- In reply to: violetaria: "Recordset to 2D Array Question"
- Next in thread: violetaria: "Re: Recordset to 2D Array Question"
- Reply: violetaria: "Re: Recordset to 2D Array Question"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|