Optimize printing of large SQL Server results through ASP

0

Today I have a classic ASP page with an unconventional chain-select (read "armengado") that returns a populated select with some data from a sql-server (2005) database.

I select the building and return the number of skill floors for delivery in this building; simple.

It works very well today; The problem is that soon I will have to add more than 600 rows in this database and the query will be very slow (since ASP needs to print all the data on the page before javascript picks up and takes to select.)

I need to know if there is a better way to fetch this data - I can do a SQL-SERVER interaction - > JSON for the data to come faster? Is there another way in ASP to popular the page faster? I need best practices in this specific example.

HTML

<div class="form-group">
    <label for="PREDIOS">PREDIOS</label>
    <%set RS = server.CreateObject ("ADODB.Recordset")
    RS.Open "select distinct PREDIOS from PI_AUTOCOMPLETAR_LOC ORDER BY PREDIOS",conn,1%>
    <select id="PREDIOS" name="PREDIOS" class="form-control" onchange="venha_lista();">
    <option value="">Selecione</option>
    <%If RS.bof And RS.eof Then
    response.write "Lista Vazia"
    Else
    While not RS.eof    
    Response.Write "<option value='"&RS("PREDIOS").value&"'>"&RS("PREDIOS").value&"</option>"
    RS.movenext
    Wend
    End If%>
     </select>
    </div>
<div id="ANDAR"></div>

Jquery

function venha_lista() {
    $.post("consulta_loc/atualizar_ANDAR.asp", $("#leva_servico").serialize(), function (data) {
        $("#ANDAR").html(data);
    });
};

upgrade_ANDAR.asp

<%set rs = server.CreateObject ("ADODB.Recordset")
PREDIO = REQUEST("PREDIO")
IF PREDIO = ""  THEN
PREDIO = "%"
end if
RS.Open "select distinct ANDAR from PI_AUTOCOMPLETAR_LOC WHERE PREDIO = '"&PREDIO&"' ORDER BY ANDAR",conn,1 %>
<select id="ANDAR" name="ANDAR" class="form-control">
<option value="">Selecione</option>
<% WHILE NOT RS.EOF %>
<option value="<%Response.write rs("ANDAR")%>"><%Response.write rs("ANDAR")%></option>
<% RS.MoveNext 
    WEND    %>
</select>
    
asked by anonymous 06.05.2015 / 13:35

1 answer

1

One way is to use response.flush within the loop.

"Seven" response.buffer=true at the beginning of your code. In the loop, ask response.flush to write the contents of the script every step of the loop ...

    
19.08.2015 / 15:10