0

This code was working up until today now I keep getting the buffer exceeded error. I'm positive there is a much better way to do this but I have no idea how.

What I'm trying to do is display any entry from the current date to two weeks out. Users can enter any date within that two week period and the table will fill the spaces in between or after with a default "GREEN" span. I had it working until today. I haven't touched it in three weeks and I have no idea what happened. I'm a lowly graphic designer who's bosses don't know the difference between html/css and asp/sql driven applications. Please help before I go insane...

        <div class="cond_holder">
        <div class="dir_name">PEDS CARDIOLOGY</div>
<%
        Dim this_day_peds_cardio
        this_day_peds_cardio = Date

        Dim Conditions_peds_cardio
        Dim Conditions_peds_cardio_cmd
        Dim Conditions_peds_cardio_numRows

        Set Conditions_peds_cardio_cmd = Server.CreateObject ("ADODB.Command")
        Conditions_peds_cardio_cmd.ActiveConnection = MM_webdbs_STRING
        Conditions_peds_cardio_cmd.CommandText = "SELECT * FROM dbo.ryg_conditions WHERE aoc='1' AND Day >= DATEADD(dd, DATEDIFF(dd, 0, GETDATE()), 0) ORDER BY aoc ASC, Day ASC" 
        Conditions_peds_cardio_cmd.Prepared = true

        Set Conditions_peds_cardio = Conditions_peds_cardio_cmd.Execute
        Conditions_peds_cardio_numRows = 0

        Dim Repeat_peds_cardio__numRows
        Dim Repeat_peds_cardio__index

        Repeat_peds_cardio__numRows = 14
        Repeat_peds_cardio__index = 0
        Conditions_peds_cardio_numRows = Conditions_peds_cardio_numRows + Repeat_peds_cardio__numRows

        While ((Repeat_peds_cardio__numRows <> 0) AND (NOT Conditions_peds_cardio.EOF)) 
            If DateDiff("d", (Conditions_peds_cardio.Fields.Item("Day").Value), this_day_peds_cardio)=0  Then
%>
                <span class="daily_condition <%=(Conditions_peds_cardio.Fields.Item("ryg").Value)%>">
                    <span style="display: none;"><%=(Conditions_peds_cardio.Fields.Item("aoc").Value)%></span>
                    <%=(Conditions_peds_cardio.Fields.Item("ryg").Value)%>
                    <span class="reason"><%=(Conditions_peds_cardio.Fields.Item("reasoning").Value)%></span>
                </span><!-- /.daily_condtion -->
<%
                this_day_peds_cardio = DateAdd("d", 1, this_day_peds_cardio)
            Else 
                While DateDiff("d", (Conditions_peds_cardio.Fields.Item("Day").Value), this_day_peds_cardio)<>0
%>  
                    <span class="daily_condition GREEN">GREEN</span><!-- SPACER -->
<%
                    this_day_peds_cardio = DateAdd("d", 1, this_day_peds_cardio)
                Wend
%>
                <span class="daily_condition <%=(Conditions_peds_cardio.Fields.Item("ryg").Value)%>">
                    <span style="display: none;"><%=(Conditions_peds_cardio.Fields.Item("aoc").Value)%></span>
                    <%=(Conditions_peds_cardio.Fields.Item("ryg").Value)%>
                    <span class="reason"><%=(Conditions_peds_cardio.Fields.Item("reasoning").Value)%></span>
                </span><!-- /.daily_condtion -->

<%
                this_day_peds_cardio = DateAdd("d", 1, this_day_peds_cardio)
            End if

            Repeat_peds_cardio__index=Repeat_peds_cardio__index+1
            Repeat_peds_cardio__numRows=Repeat_peds_cardio__numRows-1
            Conditions_peds_cardio.MoveNext()
        Wend

        While loop_ctr_peds_cardio < 14
%>
            <span class="daily_condition GREEN">GREEN</span><!-- FILLER -->
<%
            loop_ctr_peds_cardio = loop_ctr_peds_cardio +1
        Wend
%>
    </div><!-- /#cond_holder -->
Reporter
  • 3,897
  • 5
  • 33
  • 47
Jason G
  • 17
  • 3

2 Answers2

0

When I read your source code, I came up with two thinks:

  1. You use too many script tags (<% %>), even to seperate vbscript code. This overusing makes it hard to read and understand your code. I had to paste your source code into Notepad++ to tidy up and reading your code.
  2. You didn't use a recordset for the first while query. If you want loop through a result of a Selectquery use the recordset object. It is more convinence to handle and prevents some general errors. Does the using of a recordset eleminate your error?

To your problem:

Do you use an IIS6.0 or higher? If so then following ideas could help (I got it from a german! site of Microsoft, posted in stackoverflow.com (see here). The idears are:

  • Using Response.Flush()
  • Turn the Response.Buffer off on the page, or on the entire site. Response.Buffer = False at the top of the page before any ASP code.
  • Increase the size of the buffer (see the link on 'see here' position).
  • Decrase the size of your response.
Community
  • 1
  • 1
Reporter
  • 3,897
  • 5
  • 33
  • 47
  • Thank for your input on the code formatting. I'm trying to find the best way to format but I am still very new and this is how I was shown to do it. We are using IIS6 and I've tried the Response.Buffer = False but it breaks the page and while it will display, a timeout occurs and then forces IE (yes i'm forced to use only IE) will quit. I am going to try Response.Flush and see what happens. Thanks again! – Jason G Dec 21 '11 at 15:45
0

The reason your response buffer is overflowing is because you have more data to show now. The quickest way to get it sorted should be to issue a Response.Flush every couple of rows or so (depending on how big the response buffer is) inside your while loop. Turning off the response buffer will almost always result in the page taking longer to render, especially if you have lots of context switches like you do.

My Other Me
  • 5,007
  • 6
  • 41
  • 48