R
Rabbit63
Hi:
I want to show a set of records in the database table on the clicnt browser.
I have two ways to do this (writen in JScript):
1.The first way is:
<%
var sql = "select firstname from table1";
var obj=new ActiveXObject("ADODB.Recordset");
obj.open(sql, conn);
while(!obj.EOF)
{
Response.write(obj("firstname") + "<br>");
obj.movenext();
}
obj.close();
%>
2. The second way is:
<%
var arr=new Array();
var sql = "select firstname from table1";
var obj=new ActiveXObject("ADODB.Recordset");
obj.open(sql, conn);
while(!obj.EOF)
{
arr[arr.length] = new String(obj("firstname"));
obj.movenext();
}
obj.close();
.......
for(i=0;i<arr.length;i++)
{
document.write(arr + "<br>");
}
%>
I think the second way is more flexible but it will take nuch more memory
than the first way, because the array "arr" will take more memory. Am I
correct? Do you think the second way will need more server resources? Do you
have better idea to improve the second way?
The reason that I tried the second way is that I wanted to make my server
side programs (most writen in JScript) be object-based (not OOP) programming
style. But I am doubt that the object-based programs will take much more
memory or server resources.
Thank you very much!
Qing
I want to show a set of records in the database table on the clicnt browser.
I have two ways to do this (writen in JScript):
1.The first way is:
<%
var sql = "select firstname from table1";
var obj=new ActiveXObject("ADODB.Recordset");
obj.open(sql, conn);
while(!obj.EOF)
{
Response.write(obj("firstname") + "<br>");
obj.movenext();
}
obj.close();
%>
2. The second way is:
<%
var arr=new Array();
var sql = "select firstname from table1";
var obj=new ActiveXObject("ADODB.Recordset");
obj.open(sql, conn);
while(!obj.EOF)
{
arr[arr.length] = new String(obj("firstname"));
obj.movenext();
}
obj.close();
.......
for(i=0;i<arr.length;i++)
{
document.write(arr + "<br>");
}
%>
I think the second way is more flexible but it will take nuch more memory
than the first way, because the array "arr" will take more memory. Am I
correct? Do you think the second way will need more server resources? Do you
have better idea to improve the second way?
The reason that I tried the second way is that I wanted to make my server
side programs (most writen in JScript) be object-based (not OOP) programming
style. But I am doubt that the object-based programs will take much more
memory or server resources.
Thank you very much!
Qing