问题描述
嗨:
我想在clicnt浏览器的数据库表中显示一组记录。
我有两种方法可以做到这一点(用JScript编写):
1.第一种方式是:
<%
var sql = 从table1中选择firstname;
var obj = new ActiveXObject(" ADODB.Recordset");
obj.open(sql,conn);
while(!obj.EOF)
{
Response.write(obj(" firstname")+"< br>") ;
obj.movenext();
}
obj.close();
%>
<%
var arr = new Array();
var sql ="从table1中选择firstname" ;;
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 [i] +"< br>");
}
%>
我认为第二种方式更灵活,但它比第一种方式需要更多的内存,因为数组arr会留下更多的记忆。我是/ b $ b正确吗?您认为第二种方式需要更多服务器资源吗?你有没有更好的想法改善第二种方式?
我尝试第二种方式的原因是我想让我的服务器
辅助程序(大多数用JScript编写)是基于对象的(不是OOP)编程
样式。但我怀疑基于对象的程序将需要更多的内存或服务器资源。
非常感谢你!
Qing
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[i] + "<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
推荐答案
重新阅读他的帖子。他在服务器上使用JScript,所以没有必要将记录集设置为NOTHING(也不是这样做的)。
而且我不相信第二个会更快。
VBScript / IIS4可能是这样,但这是完全不同的情况。正如其他线程中提到的那样,VBScript和JScript具有不同的优势和
弱点,每个任务都比其他任务更快。
-
戴夫安德森
未经请求的商业电子邮件将以
Re-read his post. He''s using JScript on the server, so there is no need to
set the recordset to NOTHING (nor a means to do so).
And I''m unconvinced the second will be faster. That may have been true with
VBScript/IIS4, but this is a completely different situation. As has been
noted in other threads, VBScript and JScript have different strengths and
weaknesses, and each does some tasks faster than the other.
--
Dave Anderson
Unsolicited commercial email will be read at a cost of
这篇关于哪种方式会占用更多内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!