sum of a row in a column (classic asp)RSS

3 replies

Last post Jan 18, 2018 05:06 PM by tutovavera

  • sum of a row in a column (classic asp)

    Jan 15, 2018 09:37 AM|tutovavera|LINK

    hello, 

    I have a problem with my classic asp page. I want to sum every data in a row when if pages changes. the column data is not in database. I have a formula in the page. I did that in page. but when the page changes it starts over. I need all total sum. 

    <table width="100%" border="0" cellspacing="0" cellpadding="2" style="border-collapse:collapse ; border:#eaeaea 0px solid;">
    <tr bgcolor="<%=bgcolor%>" onmouseover="this.style.backgroundColor='#FFFFCC';" onmouseout="this.style.backgroundColor='';">
    <td width="5%">No</td>
    <td width="25%">Date</td>
    <td width="5%">Time</td>
    <td width="15%">Track</td>
    <td width="10%">Odd</td>
    <td width="10%">Profit</td>
    <td width="10%">Total</td>
    </tr>
    </table>

    <table width="100%" border="0" cellspacing="0" cellpadding="2" style="border-collapse:collapse ; border:#eaeaea 0px solid;">
    <td>
    <%
    Set Conn = Server.CreateObject("ADODB.Connection")
    Conn.Open "DRIVER={Microsoft Access Driver (*.mdb, *.accdb)}; DBQ=" & Server.MapPath("/HR.accdb")
    Set Rs = Server.CreateObject("aDodb.recordSet")
    Sor = "Select * from ENGBet365 order by dor desc"
    Rs.Open Sor, Conn, 1, 3



    If Rs.EOF or Rs.BOF Then
    Response.Write "<script language='javascript'>alert('No Records!');</script>"
    response.Write "<meta http-equiv='refresh' content='1; URL=?part=england'>"
    Response.End
    End If
    adet=Rs.RecordCount

    rownumber=1

    syf = Request.QueryString("syf")
    If syf="" Then
    syf=1
    End If

    Rs.PageSize = 20
    Rs.absolutepage=syf
    sayfa=Rs.pagecount
    for t=1 to Rs.PageSize
    If Rs.EOF Then exit for
    if renk mod 2 Then bgcolor = "#FFFFFF" Else bgcolor = "#f7f7f7" end if
    %>






    <table width="100%" border="0" cellspacing="0" cellpadding="2" style="border-collapse:collapse ; border:#eaeaea 0px solid;">
    <tr bgcolor="<%=bgcolor%>" onmouseover="this.style.backgroundColor='#FFFFCC';" onmouseout="this.style.backgroundColor='';">
    <td width="5%"><%=rownumber%></td>
    <td width="25%"><%=FormatDateTime(Rs("dor"),1)%></td>
    <td width="5%"><%=FormatDateTime(Rs("tor"),4)%></td>
    <td width="15%"><%=Rs("track")%></td>
    <td width="10%"><%=FormatNumber(Rs("odd"),3)%> </td>
    <td width="10%" align="right">
    <%
    ROR = Rs("Result")
    If ROR = 1 Then
    Response.Write "<font color=red>"
    Response.Write ""&ROR&""
    Response.Write "</font>"
    Else
    Response.Write ""&ROR&""
    End If
    %>
    </td>
    <td width="10%" align="right">
    <%
    Set ATA = Server.CreateObject("aDodb.recordSet")
    Sor = "Select * from Settings"
    ATA.Open Sor, Conn, 1, 3

    ROR = Rs("Result")
    If ROR = 1 Then
    TOT = ATA("Lia")*(-1)
    Response.Write "<font color=red>"
    Response.Write FormatNumber(""&TOT&"")
    Response.Write "</font>"
    Else
    TOT = ATA("Lia")/((Rs("Odd"))-1)*FormatNumber(ATA("Commission"),5)
    Response.Write FormatNumber(""&TOT&"")
    End If

    ATA.Close
    set ATA=nothing
    %>
    </td>
    <td width="10%" align="right">

    <%
    total = total + tot
    Response.Write FormatNumber(Total,2)
    %>

    </td>
    </tr>

    <%
    rownumber=rownumber+1
    renk=renk + 1
    Rs.movenext
    next
    Rs.Close
    set rs=nothing
    %>
    </table>

    </td>
    </tr>
    </table>

    <table width="100%" border="0" cellspacing="0" cellpadding="0" style="border-collapse:collapse ; border:#eaeaea 0px solid;">
    <tr>
    <td class="grey_ters">
    Page :
    <%
    for y=1 to sayfa
    If y=cint(syf ) Then
    Response.write (""&y&"")
    else
    Response.write "<span class=""beyaz""><a href='?part=england&syf="&y&"'> "&y&" </a></span>"
    End If
    next
    %>
    </td>
    </tr>
    </table>

  • Re: sum of a row in a column (classic asp)

    Jan 16, 2018 09:34 AM|Yuk Ding|LINK

    Hi tutovavera,

    To further help you about this issue, I am trying to invoke someone experienced to help look into this thread, this may take some time and as soon as we get any result, we will post back. 

    Regards

    Yuk Ding

    Yuk Ding

    MSDN Community Support
    Please remember to "Mark as Answer" the responses that resolved your issue.
  • Re: sum of a row in a column (classic asp)

    Jan 17, 2018 11:35 AM|gtscdsi|LINK

    Dear tutovavera,

    By going through the code you provided, I think the reason that variable 'total' starts over every time is because it's a local variable whose life cycle aligns with a specific page(which is corresponding to a specific request).

    To implement what you want : sum every data in a row when if pages changes, you need use global variables(Application object), please see the samples as below:

    The Application object

    Stores global variables.

    <div class="mw-highlight mw-content-ltr" dir="ltr">
    <%
    Application("Ali") = "My ASP Application"
    Response.Write "Welcome to " & Server.HTMLEncode(Application("Ali")) & "!"
    %>

    Sincerely,

    Jinjie ZHOU

    </div>
    We focus on various troubleshooting plan and solution on IIS web platform and distributed applications. Please contact us at:

    http://blogs.msdn.com/b/asiatech/
  • Re: sum of a row in a column (classic asp)

    Jan 18, 2018 05:06 PM|tutovavera|LINK

    thanks for your interest.