加快网页加载(2)

时间:2011-07-18 05:25:30

标签: sql arrays vbscript asp-classic

之前我曾经问过一个类似的问题,我收到了修复我的多维数组以便用getrows更快地接收记录的响应。此多维数组中有超过36,000条记录返回。虽然我的其他问题的先前答案似乎没有加快我的页面。

然后我使用这个多维数组来检查某些id是否匹配,然后将权限附加到内容。

所以我的多维数组 -

'MultiDimensional Array
Dim permissionsArray
Dim permissionsCount  
connectionstring = obj_ADO.getconnectionstring               

Set c = Server.CreateObject("ADODB.Connection")
Set r = Server.CreateObject("ADODB.Recordset")
r.CursorLocation = 2 'adUseServer
c.open connectionstring
c.CursorLocation = 2 'adUseServer

SQL = "select OP_ObjectID, P_Name from l_objectpermission inner join A_Permission on op_permissionID = P_permissionID order by P_Name"

Set r = Server.CreateObject("ADODB.Recordset")
r.CursorLocation = 2 'adUseServer
r.Open SQL, c, 0, 1 'adOpenForwardOnly, adLockReadOnly
If r.BOF or r.EOF Then
   r.close()
   Set r = Nothing
Else
   permissionsArray = r.GetRows()
   permissionsCount = UBound(permissionsArray, 2)
   r.Close()
   Set r = Nothing
End If
c.Close()
Set c = Nothing

然后内容和id +使用多维数组来附加权限

    while obj_ADO.EOF(lng_RecSet) = 0           
%>
                <tr>
<%
        objID = obj_ADO.GetField("O_ObjectID", adValue, lng_RecSet)
%>
                    <td align="center" valign="top"><input type="checkbox" name="selectedRecord" value="<%=objID%>"></td>
                    <td valign="top" align="left"><font class="Content1"><%=obj_ADO.GetField("O_Name", adValue, lng_RecSet)%></font></td>
                <td valign="middle" align="center"><center><div style="text-align: left; width: 180px;">
                 <%
                for i = 0 to (permissionsCount)
                    if permissionsArray(0, i) = objID then
                        %>
                        <li style="height: 2px;">
                        <%=permissionsArray(1,i)%>
                        </li>
                        </br>
                        <%
                    end if                        
                next   
                %>
                </div></center></td>
        </tr>
<%
        obj_ADO.MoveNext(lng_RecSet)
    wend
    obj_ADO.CloseRecordset lng_RecSet
%>

1 个答案:

答案 0 :(得分:1)

通过更改加载到多维数组中的内容来解决此问题。而不是通过用户过滤

加载我加载的所有内容
if str_Prefix = "" then
    SQL = "select OP_ObjectID, P_Name from l_objectpermission inner join A_Permission on op_permissionID = P_permissionID order by P_Name"
elseif str_Prefix <> "" then
    SQL = "select OP_ObjectID, P_Name from l_objectpermission inner join A_Permission on op_permissionID = P_permissionID where P_Name like '" & str_Prefix & "' + '%' OR P_Name like '% ' + '" & str_Prefix & "' + '%' order by P_Name"
else
    SQL = "select OP_ObjectID, P_Name from l_objectpermission inner join A_Permission on op_permissionID = P_permissionID order by P_Name"
end if