Step-thru code - odd behavior

G

Guest

I have a breakpoint in an aspx page that I'm using to try to trap some code
to see what's going on. I'm translating a page that is working in a
traditional ASP page, which takes several session variables, formats a
header, and assigns a sql stored procedure to be run and a report generated
in a web browser.


The odd behavior occurs where I have my breakpoint, which is at the place
where the variable "showblank" is set to = " ". It'll hit the next
couple of lines, then skip down into the middle of the if rstemp.EOF code -
like on the second response.write.

It then skips all over the place within the code, in the middle of if
statements, then on down thru the script at the bottom of the page. It
eventually gives me the error:

"Server Error in '/test' Application.
----------------------------------------------------------------------------
----
Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Source Error:

[No relevant source lines]


Source File: c:\inetpub\wwwroot\test\sales\reportASP.aspx Line: 409

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an
object.]

ASP.reportasp_aspx.__Render__control1(HtmlTextWriter __output, Control
parameterContainer) in c:\inetpub\wwwroot\test\sales\reportASP.aspx:409

System.Web.UI.Control.RenderChildren(HtmlTextWriter
writer)System.Web.UI.Control.Render(HtmlTextWriter writer)

System.Web.UI.Control.RenderControl(HtmlTextWriter writer)

System.Web.UI.Page.ProcessRequestMain()

----------------------------------------------------------------------------
----

Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET
Version:1.1.4322.573 "



What appears to happen to generate the error is that it skips beyond the end
of the .aspx page.

The parameter files are pieces that were originally Include files that were
supposed to be called when it was run, but I pulled them into the
codebehind. They basically are if statements that set several session
variables that control what stored procedure is run and information we put
on the header of the report page.

I'm lost as to why it skips around like it does. I have several asp pages
in front of this one that have been converted, and they all seem to follow
thru a logical step through, but not this one.

Any advice/help appreciated.

SC

The code follows:

<%@ Page language="vb" src="ReportASP.aspx.vb"
Inherits="reportASP.ReportASP_aspx_vb" Codebehind="reportasp.aspx.vb"
Debug="true" %>
<%@ Import Namespace = "nce.vbscript" %>
<!--#include file="reportheader.inc"-->
<% Exceptions() %>
<!-------------------------------------------------------------------->
<%

SetSaveAsName()

%>


<html>

<head>
<title>My Website Report</title>
</head>

<body link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF" topmargin="1">

<table border="0" width="100%">
<tr>
<td width="100%"><p align="center"><!--#include
file="remheader4d.inc"--> </td>
</tr>
<tr>
<%
FormatReportHeader()

%>

<%
If Ammospool = "" Then
If Session("rpt").ToString() = "QW" Then %>
<td width="100%"><p align="center"><font
color="#000000"><strong><small>Report:&nbsp; </small><%=
Session("RptJnumber") & " " & Session("rptYear") & " " & Session("Select") &
" " & AmmoSelect & " " & Session("ammo") & " " & Session("ranking")
%><small>
<%
Else %>
<td width="100%"><p align="center"><font
color="#000000"><strong><small>Report:&nbsp; </small><%=
Session("RptJnumber") & " " & Session("rptYear") & " Year " &
Session("Select") & " " & AmmoSelect & " " & Session("ammo") & " " &
Session("ranking") %><small>
<% End IF
Else %>
</small></strong></font></td>
<%
If Session("rpt").ToString() = "TAR" Or Session("rpt").ToString() =
"MBM" Then
%>
<td width="100%"><p align="center"><font
color="#000000"><strong><small>Report:&nbsp; </small><%=
Session("RptJnumber") & " " & Session("rptYear") & " Year " &
Session("Select") & " " & " " & Session("ranking") %><small>
<% Else
If Session("select").ToString() = "J7QSUM" Or
Session("select").ToString() = "J7QDETAIL" Or Session("select").ToString() =
"J7QSINGLE" Or Session("select").ToString() = "J7QSKU" Then
%>
<td width="100%"><p align="center"><font
color="#000000"><strong><small>Report:&nbsp; </small><%=
Session("RptJnumber") & " " & Session("rptYear") & " Year " &
Session("ranking") %><small>
<% Else %>
<td width="100%"><p align="center"><font
color="#000000"><strong><small>Report:&nbsp; </small><%=
Session("RptJnumber") & " " & Session("rptYear") & " Year " &
Session("Select") & " " & Ammospool & " " & Session("ranking") %><small>
<% End IF
End IF
End IF
%>
</small></strong></font></td>
</tr>
<tr>
<td width="100%"><p align="center"><font color="#000000"><small>Last
Updated: <%= __when %>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Report Date:&nbsp;</small> <small><%= Today()
%></small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Report
Time:&nbsp;<%= TimeOfDay() %></small> <big><strong>&nbsp;</strong></big>
&nbsp;</font></td>
</tr>
<% SessionParameters() %>
<tr>
<td width="100%"><small><p align="center"><font color="#000000"><b>(
Selection: <%= Session("Selection") & " " & Session("POs")
%>)</b></font></small></td>
</tr>
</table>

<% J3Parameters() %>
<% J4Parameters() %>
<% J5Parameters() %>
<% J6Parameters() %>
<% J7Parameters() %>
<% J9Parameters() %>
<% I1Parameters() %>
<% rebateparameters() %>
<% springparameters() %>
<% qualificationparameters() %>
<% coopparameters() %>
<% specialreports() %>

<%

showblank = "&nbsp;"
shownull = "-null-"
conntemp = new ADODB.Connection()
conntemp.connectionstring = session("serverstring")
'conntemp.connectiontimeout = 900 ' (Add This line)
conntemp.CommandTimeout = 2000
Server.ScriptTimeout = 2000
Session.Add("rptstart", Timer())
conntemp.Open()
rstemp = conntemp.Execute(mySQL)
If rstemp.EOF Then
Response.Write("<b>No records matched<br>")
Response.Write(mySQL & "<br>So cannot make table...</b>")
conntemp.Close()
conntemp = Nothing
Response.End()
End IF
If Session("user").ToString() = "CHATHAMSC" Then
Response.Write(mySQL)
'for each strkey in session.contents
'response.write "(" & Session.contents.key(strkey) & ") " &
session.contents.item(strkey)& "<BR>"
'next
'' for each strkey in session.contents
'' if session.contents.item(strkey) <> "" then
'' response.write "(" & Session.contents.key(strkey) & ") " &
session.contents.item(strkey)& "<BR>"
'' end if
'' next
End IF
%>

<%
If (Session("Year").ToString() = "Sales" Or Session("Year").ToString() =
"Calendar") AND ((Session("Select").ToString() = "Material Number" AND
Session("matdesc").ToString() <> "") Or (Session("rpt").ToString() = "J6"
AND Session("select").ToString() = "Detail") Or (Session("rpt").ToString() =
"J5" AND Session("select").ToString() = "Detail")) Or
(Session("rpt").ToString() = "QD" Or Session("rpt").ToString() = "QW" Or
Session("rpt").ToString() = "MBM") Then
%>

<table border="9" align="center"
style="font-family: Arial; font-size: 8pt; border: medium none"
bordercolor="#000000">
<%
Else
%>

<tr>
<td><table border="9" align="center"
style="font-family: Arial; font-size: 9pt; border: medium none"
bordercolor="#000000">
<%
End IF
%>

<tr>
<%
'Put Headings On The Table of Field Names
'redim sData(rs.recordcount,175)
rownumber = 3
colnumber = 0
BeenThere = 0
lcnt = 0
numcols = 0
actualcols = 0
NrGroups = 0
For Each WhatCol In rstemp.Fields
If Len(WhatCol.Name) <> 1 Then
thisfield = WhatCol.Name
GroupField(lcnt) = 0
numcols = numcols + 1
%>

<td bgcolor="#FFFFFF" align="center"><p align="center"><font
color="#000000"><b><%= thisfield %></b></font></td>
<%
Else
'All 1 Character Field Names are Grouping Fields
'This sets up the grouping with hierachy determined from left to
right in SQL
GroupField(lcnt) = 1
NrGroups = NrGroups + 1
End IF
actualcols = actualcols + 1
lcnt = lcnt + 1
Next
TBorder = "border:medium none "
'TBorder = "border-left: medium none; border-right: medium none;
border-top: medium double; border-bottom: medium none"
%>

</tr>
<%
'Now lets grab all the records
rownumber = 3
bgcolor = "white"
Do Until rstemp.EOF
%>

<tr>
<%
lcnt = 0
'Prepare Row for Printing
For Each WhatCol In rstemp.Fields
'Load data to array
sData(rownumber, lcnt) = WhatCol.Value
'If Data Type is currency, real or float
'response.write "QQ" & whatcol.type & "ZZ"
'response.write "name = " & whatcol.name
If WhatCol.Type = 6 Or WhatCol.Type = 5 Then
GrandTotal(lcnt + 1, 0) = GrandTotal(lcnt + 1, 0) +
WhatCol.Value
End IF
'Suppress Duplicates for Printing
'Set up the first row for Grouping
If rownumber = 3 Then
sData(rownumber - 1, lcnt) = WhatCol.Value
End IF
If (sData(rownumber, lcnt) = sData(rownumber - 1, lcnt)) AND
(WhatCol.Type <> 5 AND WhatCol.Type <> 6) Then
If rownumber = 3 Then
thisfield = WhatCol.Value
GroupField(lcnt) = GroupField(lcnt) + 1
Else
'Added the linecount < NrGroups times 2 which not
suppress duplicates on any field except Group Fields
'If you need to change it back insert (thisfield =
showblank) in place of If Statement.
If lcnt < (NrGroups * 2) + 1 Then
thisfield = showblank
GroupField(lcnt) = GroupField(lcnt) + 1
Else
thisfield = WhatCol.Value
End IF
End IF
Else
thisfield = sData(rownumber, lcnt)
GroupField(lcnt) = 0
End IF
'Total Rows Field Length is 1 Character
If Len(WhatCol.Name) <> 1 Then
If WhatCol.Type = 6 Or WhatCol.Type = 5 Then
thisfield = FormatNumber(CDbl(thisfield), 0)
End IF
%>

<td bgcolor="<%= bgcolor %>" valign="top" align="right"
style="border: medium none"><%= thisfield %>
<%
End IF
lcnt = lcnt + 1
Next
rstemp.MoveNext()
'set or reset data
ralign = "right"
'Change colors for every other line
If chgcolor = 0 Then
bgcolor = "#FFFFCC"
chgcolor = 1
Else
bgcolor = "White"
chgcolor = 0
End IF
'End Totals and Grouping
lcnt = 0
If Not rstemp.EOF Then
For Each WhatCol In rstemp.Fields
If Len(WhatCol.Name) = 1 Then
If WhatCol.Value.ToString() <> CStr(sData(rownumber,
lcnt)) Then
PrintTotal(lcnt) = lcnt
GroupField(lcnt) = 1
Else
'if rownumber<>3 then
rowCnt(lcnt) = rowCnt(lcnt) + 1
'end if
GroupField(lcnt) = 0
End IF
lcnt = lcnt + 1
End IF
Next
End IF
If rstemp.EOF Then
lcnt = 0
For Each WhatCol In rstemp.Fields
If Len(WhatCol.Name) = 1 Then
If sData(rownumber - 1, lcnt) = sData(rownumber, lcnt)
AND CStr(sData(rownumber, lcnt)) <> "" Then
PrintTotal(lcnt) = lcnt
GroupField(lcnt) = 1
'rowcnt(lcnt) = rowcnt(lcnt)+1
Else
PrintTotal(lcnt) = NrGroups + 1
'if rownumber<>3 then
rowCnt(lcnt) = 0
'end if
GroupField(lcnt) = 0
End IF
'lcnt = lcnt + 1
End IF
lcnt = lcnt + 1
Next
End IF
lcnt = 0
iGroup = 0
For tcnt = 0 To NrGroups
pcnt = NrGroups - tcnt
If CInt(PrintTotal(pcnt)) < NrGroups AND (CInt(GroupField(pcnt))
= 1 AND CInt(rowCnt(pcnt)) > 0) Then
GroupField(pcnt) = 0
'rowcnt(pcnt) = 0
If CInt(rowCnt(pcnt)) > 0 Then
Response.Write("</tr><tr>")
End IF
For Each WhatCol In rstemp.Fields
If Len(WhatCol.Name) <> 1 Then
If CInt(rowCnt(pcnt)) < 1 AND (WhatCol.Type = 5 AND
WhatCol.Type = 6) Then
GrpTotal(lcnt, PrintTotal(pcnt)) = 0
End IF
If Len(WhatCol.Name) <> 1 AND (WhatCol.Type <> 5 AND
WhatCol.Type <> 6) Then
If lcnt = CInt((NrGroups) + PrintTotal(pcnt))
Then
sTotals = CStr(sData(rownumber, lcnt))
'& "-" & rowcnt(pcnt) & WHATCOL.TYPE
Else
sTotals = showblank
End IF
If CInt(rowCnt(pcnt)) > 0 Then
Response.Write("<TD style=" & TBorder & "
ALIGN=" & ralign & " BGCOLOR=" & bgcolor & "><STRONG>" & sTotals &
"</FONT></STRONG></TD>")
End IF
End IF
If Len(WhatCol.Name) <> 1 AND (WhatCol.Type = 5 Or
WhatCol.Type = 6) Then
For colcount = 0 To rowCnt(pcnt)
atotals = sData(rownumber - colcount, lcnt)
+ atotals
Next
atotals = FormatNumber(CDbl(atotals), 0)
If CInt(rowCnt(pcnt)) > 0 Then
Response.Write("<TD style=" & TBorder & "
ALIGN=" & ralign & " BGCOLOR=" & bgcolor & "><STRONG>" & atotals &
"</FONT></STRONG></TD>")
End IF
GrpTotal(lcnt, PrintTotal(pcnt)) = 0
atotals = 0
End IF
End IF
lcnt = lcnt + 1
Next
If CInt(rowCnt(pcnt)) > 0 Then
Response.Write("</tr><tr>")
BeenThere = BeenThere + 1
End IF
rowCnt(pcnt) = 0
'Change colors for every other line
If chgcolor = 0 Then
bgcolor = "#FFFFCC"
chgcolor = 1
Else
bgcolor = "White"
chgcolor = 0
End IF
End IF
lcnt = 0
Next
rownumber = rownumber + 1
Loop
%>

</td>
</tr>
<tr>
<%
'Grand Total Routine
lcnt = 0
col1 = 0
If NrGroups > 0 Then
'If any 1 character fields where defined, Grand Totals will appear
For Each WhatCol In rstemp.Fields
If WhatCol.Type = 6 Or WhatCol.Type = 5 Then
sTotal = FormatNumber(CDbl(GrandTotal(lcnt + 1, 0)), 0)
%>

<td bgcolor="<%= bgcolor %>" valign="top" align="right"
style="border-left: medium none; border-right: medium none;
border-top: medium double; border-bottom: medium none"><strong><%= (sTotal)
%></strong>
<%
sTotal = 0
Else
If Len(WhatCol.Name) <> 1 Then
If col1 = 0 Then
sTotal1 = "Grand Total"
col1 = 1
Else
sTotal1 = showblank
End IF
Else
sTotal1 = showblank
End IF
If Len(WhatCol.Name) <> 1 Then
%>
</td>
<td bgcolor="<%= bgcolor %>" valign="top" align="right"
style="border-left: medium none; border-right: medium none;
border-top: medium double; border-bottom: medium none"><strong><%= sTotal1
%></strong>
<%
End IF
End IF
lcnt = lcnt + 1
Next
%>
</td>
</tr>
<%
End IF
Session.Add("rptend", Timer())
Session.Add("rpttime", FormatNumber(CDbl(Session("rptend")) -
CDbl(Session("rptstart")), 1))
rstemp.Close()
rstemp = Nothing
conntemp.Close()
conntemp = Nothing
%>

</table>
<p><small><%
Response.Write("The report ran in " & Session("rpttime") & " second(s)")
%>
</small></td>
</tr>
</table>
<!-------------------------------------------------------------------->

</body>
<script LANGUAGE="VBSCRIPT">
<!--
sub window_onload
updatestatus
end sub
Sub UpdateStatus
Status = "<%= mySQL %>"
end sub

-->
</script>

</html>
 
M

Manish

delete the dll & pdb file in bin folder and rebuild your solution.

--


------------------------------------
Make Unlimited phone calls from your PC to ANY phone in the World!
http://www.eboom.com/free/
I have a breakpoint in an aspx page that I'm using to try to trap some code
to see what's going on. I'm translating a page that is working in a
traditional ASP page, which takes several session variables, formats a
header, and assigns a sql stored procedure to be run and a report generated
in a web browser.


The odd behavior occurs where I have my breakpoint, which is at the place
where the variable "showblank" is set to = "&nbsp;". It'll hit the next
couple of lines, then skip down into the middle of the if rstemp.EOF code -
like on the second response.write.

It then skips all over the place within the code, in the middle of if
statements, then on down thru the script at the bottom of the page. It
eventually gives me the error:

"Server Error in '/test' Application.
-------------------------------------------------------------------------- --
----
Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Source Error:

[No relevant source lines]


Source File: c:\inetpub\wwwroot\test\sales\reportASP.aspx Line: 409

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an
object.]

ASP.reportasp_aspx.__Render__control1(HtmlTextWriter __output, Control
parameterContainer) in c:\inetpub\wwwroot\test\sales\reportASP.aspx:409

System.Web.UI.Control.RenderChildren(HtmlTextWriter
writer)System.Web.UI.Control.Render(HtmlTextWriter writer)

System.Web.UI.Control.RenderControl(HtmlTextWriter writer)

System.Web.UI.Page.ProcessRequestMain()

-------------------------------------------------------------------------- --
----

Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET
Version:1.1.4322.573 "



What appears to happen to generate the error is that it skips beyond the end
of the .aspx page.

The parameter files are pieces that were originally Include files that were
supposed to be called when it was run, but I pulled them into the
codebehind. They basically are if statements that set several session
variables that control what stored procedure is run and information we put
on the header of the report page.

I'm lost as to why it skips around like it does. I have several asp pages
in front of this one that have been converted, and they all seem to follow
thru a logical step through, but not this one.

Any advice/help appreciated.

SC

The code follows:

<%@ Page language="vb" src="ReportASP.aspx.vb"
Inherits="reportASP.ReportASP_aspx_vb" Codebehind="reportasp.aspx.vb"
Debug="true" %>
<%@ Import Namespace = "nce.vbscript" %>
<!--#include file="reportheader.inc"-->
<% Exceptions() %>
<!-------------------------------------------------------------------->
<%

SetSaveAsName()

%>


<html>

<head>
<title>My Website Report</title>
</head>

<body link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF" topmargin="1">

<table border="0" width="100%">
<tr>
<td width="100%"><p align="center"><!--#include
file="remheader4d.inc"--> </td>
</tr>
<tr>
<%
FormatReportHeader()

%>

<%
If Ammospool = "" Then
If Session("rpt").ToString() = "QW" Then %>
<td width="100%"><p align="center"><font
color="#000000"><strong><small>Report:&nbsp; </small><%=
Session("RptJnumber") & " " & Session("rptYear") & " " & Session("Select") &
" " & AmmoSelect & " " & Session("ammo") & " " & Session("ranking")
%><small>
<%
Else %>
<td width="100%"><p align="center"><font
color="#000000"><strong><small>Report:&nbsp; </small><%=
Session("RptJnumber") & " " & Session("rptYear") & " Year " &
Session("Select") & " " & AmmoSelect & " " & Session("ammo") & " " &
Session("ranking") %><small>
<% End IF
Else %>
</small></strong></font></td>
<%
If Session("rpt").ToString() = "TAR" Or Session("rpt").ToString() =
"MBM" Then
%>
<td width="100%"><p align="center"><font
color="#000000"><strong><small>Report:&nbsp; </small><%=
Session("RptJnumber") & " " & Session("rptYear") & " Year " &
Session("Select") & " " & " " & Session("ranking") %><small>
<% Else
If Session("select").ToString() = "J7QSUM" Or
Session("select").ToString() = "J7QDETAIL" Or Session("select").ToString() =
"J7QSINGLE" Or Session("select").ToString() = "J7QSKU" Then
%>
<td width="100%"><p align="center"><font
color="#000000"><strong><small>Report:&nbsp; </small><%=
Session("RptJnumber") & " " & Session("rptYear") & " Year " &
Session("ranking") %><small>
<% Else %>
<td width="100%"><p align="center"><font
color="#000000"><strong><small>Report:&nbsp; </small><%=
Session("RptJnumber") & " " & Session("rptYear") & " Year " &
Session("Select") & " " & Ammospool & " " & Session("ranking") %><small>
<% End IF
End IF
End IF
%>
</small></strong></font></td>
</tr>
<tr>
<td width="100%"><p align="center"><font color="#000000"><small>Last
Updated: <%= __when %>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Report Date:&nbsp;</small> <small><%= Today()
%></small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Report
Time:&nbsp;<%= TimeOfDay() %></small>
 
G

Guest

I tried this. Went in, found the dll & pdb file, and deleted them, then
opened Visual Studio 2003 and ran the application, hitting the same
breakpoint in the code. The breakpoint cursor would then skip about to the
same lines in the code (i.e. the 3rd statement inside an IF statement,
without ever hitting the if statement), until it appeared to be trying to
run beyond the end of the report.aspx file.

SC


Manish said:
delete the dll & pdb file in bin folder and rebuild your solution.

--


------------------------------------
Make Unlimited phone calls from your PC to ANY phone in the World!
http://www.eboom.com/free/
I have a breakpoint in an aspx page that I'm using to try to trap some code
to see what's going on. I'm translating a page that is working in a
traditional ASP page, which takes several session variables, formats a
header, and assigns a sql stored procedure to be run and a report generated
in a web browser.


The odd behavior occurs where I have my breakpoint, which is at the place
where the variable "showblank" is set to = "&nbsp;". It'll hit the next
couple of lines, then skip down into the middle of the if rstemp.EOF code -
like on the second response.write.

It then skips all over the place within the code, in the middle of if
statements, then on down thru the script at the bottom of the page. It
eventually gives me the error:

"Server Error in '/test' Application.
--------------------------------------------------------------------------
--
----
Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Source Error:

[No relevant source lines]


Source File: c:\inetpub\wwwroot\test\sales\reportASP.aspx Line: 409

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an
object.]

ASP.reportasp_aspx.__Render__control1(HtmlTextWriter __output, Control
parameterContainer) in c:\inetpub\wwwroot\test\sales\reportASP.aspx:409

System.Web.UI.Control.RenderChildren(HtmlTextWriter
writer)System.Web.UI.Control.Render(HtmlTextWriter writer)

System.Web.UI.Control.RenderControl(HtmlTextWriter writer)

System.Web.UI.Page.ProcessRequestMain()

--------------------------------------------------------------------------
--
----

Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET
Version:1.1.4322.573 "



What appears to happen to generate the error is that it skips beyond the end
of the .aspx page.

The parameter files are pieces that were originally Include files that were
supposed to be called when it was run, but I pulled them into the
codebehind. They basically are if statements that set several session
variables that control what stored procedure is run and information we put
on the header of the report page.

I'm lost as to why it skips around like it does. I have several asp pages
in front of this one that have been converted, and they all seem to follow
thru a logical step through, but not this one.

Any advice/help appreciated.

SC

The code follows:

<%@ Page language="vb" src="ReportASP.aspx.vb"
Inherits="reportASP.ReportASP_aspx_vb" Codebehind="reportasp.aspx.vb"
Debug="true" %>
<%@ Import Namespace = "nce.vbscript" %>
<!--#include file="reportheader.inc"-->
<% Exceptions() %>
<!-------------------------------------------------------------------->
<%

SetSaveAsName()

%>


<html>

<head>
<title>My Website Report</title>
</head>

<body link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF" topmargin="1">

<table border="0" width="100%">
<tr>
<td width="100%"><p align="center"><!--#include
file="remheader4d.inc"--> </td>
</tr>
<tr>
<%
FormatReportHeader()

%>

<%
If Ammospool = "" Then
If Session("rpt").ToString() = "QW" Then %>
<td width="100%"><p align="center"><font
color="#000000"><strong><small>Report:&nbsp; </small><%=
Session("RptJnumber") & " " & Session("rptYear") & " " &
Session("Select")
&
" " & AmmoSelect & " " & Session("ammo") & " " & Session("ranking")
%><small>
<%
Else %>
<td width="100%"><p align="center"><font
color="#000000"><strong><small>Report:&nbsp; </small><%=
Session("RptJnumber") & " " & Session("rptYear") & " Year " &
Session("Select") & " " & AmmoSelect & " " & Session("ammo") & " " &
Session("ranking") %><small>
<% End IF
Else %>
</small></strong></font></td>
<%
If Session("rpt").ToString() = "TAR" Or
Session("rpt").ToString()
=
"MBM" Then
%>
<td width="100%"><p align="center"><font
color="#000000"><strong><small>Report:&nbsp; </small><%=
Session("RptJnumber") & " " & Session("rptYear") & " Year " &
Session("Select") & " " & " " & Session("ranking") %><small>
<% Else
If Session("select").ToString() = "J7QSUM" Or
Session("select").ToString() = "J7QDETAIL" Or
Session("select").ToString()
=
"J7QSINGLE" Or Session("select").ToString() = "J7QSKU" Then
%>
<td width="100%"><p align="center"><font
color="#000000"><strong><small>Report:&nbsp; </small><%=
Session("RptJnumber") & " " & Session("rptYear") & " Year " &
Session("ranking") %><small>
<% Else %>
<td width="100%"><p align="center"><font
color="#000000"><strong><small>Report:&nbsp; </small><%=
Session("RptJnumber") & " " & Session("rptYear") & " Year " &
Session("Select") & " " & Ammospool & " " & Session("ranking") %><small>
<% End IF
End IF
End IF
%>
</small></strong></font></td>
</tr>
<tr>
<td width="100%"><p align="center"><font color="#000000"><small>Last
Updated: <%= __when %>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Report Date:&nbsp;</small> <small><%= Today()
%></small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Report
Time:&nbsp;<%= TimeOfDay() %></small>
&nbsp;</font></td>
</tr>
<% SessionParameters() %>
<tr>
<td width="100%"><small><p align="center"><font color="#000000"><b>(
Selection: <%= Session("Selection") & " " & Session("POs")
%>)</b></font></small></td>
</tr>
</table>

<% J3Parameters() %>
<% J4Parameters() %>
<% J5Parameters() %>
<% J6Parameters() %>
<% J7Parameters() %>
<% J9Parameters() %>
<% I1Parameters() %>
<% rebateparameters() %>
<% springparameters() %>
<% qualificationparameters() %>
<% coopparameters() %>
<% specialreports() %>

<%

showblank = "&nbsp;"
shownull = "-null-"
conntemp = new ADODB.Connection()
conntemp.connectionstring = session("serverstring")
'conntemp.connectiontimeout = 900 ' (Add This line)
conntemp.CommandTimeout = 2000
Server.ScriptTimeout = 2000
Session.Add("rptstart", Timer())
conntemp.Open()
rstemp = conntemp.Execute(mySQL)
If rstemp.EOF Then
Response.Write("<b>No records matched<br>")
Response.Write(mySQL & "<br>So cannot make table...</b>")
conntemp.Close()
conntemp = Nothing
Response.End()
End IF
If Session("user").ToString() = "CHATHAMSC" Then
Response.Write(mySQL)
'for each strkey in session.contents
'response.write "(" & Session.contents.key(strkey) & ") " &
session.contents.item(strkey)& "<BR>"
'next
'' for each strkey in session.contents
'' if session.contents.item(strkey) <> "" then
'' response.write "(" & Session.contents.key(strkey) & ") " &
session.contents.item(strkey)& "<BR>"
'' end if
'' next
End IF
%>

<%
If (Session("Year").ToString() = "Sales" Or
Session("Year").ToString()
=
"Calendar") AND ((Session("Select").ToString() = "Material Number" AND
Session("matdesc").ToString() <> "") Or (Session("rpt").ToString() = "J6"
AND Session("select").ToString() = "Detail") Or
(Session("rpt").ToString()
=
"J5" AND Session("select").ToString() = "Detail")) Or
(Session("rpt").ToString() = "QD" Or Session("rpt").ToString() = "QW" Or
Session("rpt").ToString() = "MBM") Then
%>

<table border="9" align="center"
style="font-family: Arial; font-size: 8pt; border: medium none"
bordercolor="#000000">
<%
Else
%>

<tr>
<td><table border="9" align="center"
style="font-family: Arial; font-size: 9pt; border: medium none"
bordercolor="#000000">
<%
End IF
%>

<tr>
<%
'Put Headings On The Table of Field Names
'redim sData(rs.recordcount,175)
rownumber = 3
colnumber = 0
BeenThere = 0
lcnt = 0
numcols = 0
actualcols = 0
NrGroups = 0
For Each WhatCol In rstemp.Fields
If Len(WhatCol.Name) <> 1 Then
thisfield = WhatCol.Name
GroupField(lcnt) = 0
numcols = numcols + 1
%>

<td bgcolor="#FFFFFF" align="center"><p align="center"><font
color="#000000"><b><%= thisfield %></b></font></td>
<%
Else
'All 1 Character Field Names are Grouping Fields
'This sets up the grouping with hierachy determined from
left
to
right in SQL
GroupField(lcnt) = 1
NrGroups = NrGroups + 1
End IF
actualcols = actualcols + 1
lcnt = lcnt + 1
Next
TBorder = "border:medium none "
'TBorder = "border-left: medium none; border-right: medium none;
border-top: medium double; border-bottom: medium none"
%>

</tr>
<%
'Now lets grab all the records
rownumber = 3
bgcolor = "white"
Do Until rstemp.EOF
%>

<tr>
<%
lcnt = 0
'Prepare Row for Printing
For Each WhatCol In rstemp.Fields
'Load data to array
sData(rownumber, lcnt) = WhatCol.Value
'If Data Type is currency, real or float
'response.write "QQ" & whatcol.type & "ZZ"
'response.write "name = " & whatcol.name
If WhatCol.Type = 6 Or WhatCol.Type = 5 Then
GrandTotal(lcnt + 1, 0) = GrandTotal(lcnt + 1, 0) +
WhatCol.Value
End IF
'Suppress Duplicates for Printing
'Set up the first row for Grouping
If rownumber = 3 Then
sData(rownumber - 1, lcnt) = WhatCol.Value
End IF
If (sData(rownumber, lcnt) = sData(rownumber - 1, lcnt)) AND
(WhatCol.Type <> 5 AND WhatCol.Type <> 6) Then
If rownumber = 3 Then
thisfield = WhatCol.Value
GroupField(lcnt) = GroupField(lcnt) + 1
Else
'Added the linecount < NrGroups times 2 which not
suppress duplicates on any field except Group Fields
'If you need to change it back insert (thisfield =
showblank) in place of If Statement.
If lcnt < (NrGroups * 2) + 1 Then
thisfield = showblank
GroupField(lcnt) = GroupField(lcnt) + 1
Else
thisfield = WhatCol.Value
End IF
End IF
Else
thisfield = sData(rownumber, lcnt)
GroupField(lcnt) = 0
End IF
'Total Rows Field Length is 1 Character
If Len(WhatCol.Name) <> 1 Then
If WhatCol.Type = 6 Or WhatCol.Type = 5 Then
thisfield = FormatNumber(CDbl(thisfield), 0)
End IF
%>

<td bgcolor="<%= bgcolor %>" valign="top" align="right"
style="border: medium none"><%= thisfield %>
<%
End IF
lcnt = lcnt + 1
Next
rstemp.MoveNext()
'set or reset data
ralign = "right"
'Change colors for every other line
If chgcolor = 0 Then
bgcolor = "#FFFFCC"
chgcolor = 1
Else
bgcolor = "White"
chgcolor = 0
End IF
'End Totals and Grouping
lcnt = 0
If Not rstemp.EOF Then
For Each WhatCol In rstemp.Fields
If Len(WhatCol.Name) = 1 Then
If WhatCol.Value.ToString() <> CStr(sData(rownumber,
lcnt)) Then
PrintTotal(lcnt) = lcnt
GroupField(lcnt) = 1
Else
'if rownumber<>3 then
rowCnt(lcnt) = rowCnt(lcnt) + 1
'end if
GroupField(lcnt) = 0
End IF
lcnt = lcnt + 1
End IF
Next
End IF
If rstemp.EOF Then
lcnt = 0
For Each WhatCol In rstemp.Fields
If Len(WhatCol.Name) = 1 Then
If sData(rownumber - 1, lcnt) = sData(rownumber, lcnt)
AND CStr(sData(rownumber, lcnt)) <> "" Then
PrintTotal(lcnt) = lcnt
GroupField(lcnt) = 1
'rowcnt(lcnt) = rowcnt(lcnt)+1
Else
PrintTotal(lcnt) = NrGroups + 1
'if rownumber<>3 then
rowCnt(lcnt) = 0
'end if
GroupField(lcnt) = 0
End IF
'lcnt = lcnt + 1
End IF
lcnt = lcnt + 1
Next
End IF
lcnt = 0
iGroup = 0
For tcnt = 0 To NrGroups
pcnt = NrGroups - tcnt
If CInt(PrintTotal(pcnt)) < NrGroups AND (CInt(GroupField(pcnt))
= 1 AND CInt(rowCnt(pcnt)) > 0) Then
GroupField(pcnt) = 0
'rowcnt(pcnt) = 0
If CInt(rowCnt(pcnt)) > 0 Then
Response.Write("</tr><tr>")
End IF
For Each WhatCol In rstemp.Fields
If Len(WhatCol.Name) <> 1 Then
If CInt(rowCnt(pcnt)) < 1 AND (WhatCol.Type = 5 AND
WhatCol.Type = 6) Then
GrpTotal(lcnt, PrintTotal(pcnt)) = 0
End IF
If Len(WhatCol.Name) <> 1 AND (WhatCol.Type <> 5 AND
WhatCol.Type <> 6) Then
If lcnt = CInt((NrGroups) + PrintTotal(pcnt))
Then
sTotals = CStr(sData(rownumber, lcnt))
'& "-" & rowcnt(pcnt) & WHATCOL.TYPE
Else
sTotals = showblank
End IF
If CInt(rowCnt(pcnt)) > 0 Then
Response.Write("<TD style=" & TBorder & "
ALIGN=" & ralign & " BGCOLOR=" & bgcolor & "><STRONG>" & sTotals &
"</FONT></STRONG></TD>")
End IF
End IF
If Len(WhatCol.Name) <> 1 AND (WhatCol.Type = 5 Or
WhatCol.Type = 6) Then
For colcount = 0 To rowCnt(pcnt)
atotals = sData(rownumber - colcount, lcnt)
+ atotals
Next
atotals = FormatNumber(CDbl(atotals), 0)
If CInt(rowCnt(pcnt)) > 0 Then
Response.Write("<TD style=" & TBorder & "
ALIGN=" & ralign & " BGCOLOR=" & bgcolor & "><STRONG>" & atotals &
"</FONT></STRONG></TD>")
End IF
GrpTotal(lcnt, PrintTotal(pcnt)) = 0
atotals = 0
End IF
End IF
lcnt = lcnt + 1
Next
If CInt(rowCnt(pcnt)) > 0 Then
Response.Write("</tr><tr>")
BeenThere = BeenThere + 1
End IF
rowCnt(pcnt) = 0
'Change colors for every other line
If chgcolor = 0 Then
bgcolor = "#FFFFCC"
chgcolor = 1
Else
bgcolor = "White"
chgcolor = 0
End IF
End IF
lcnt = 0
Next
rownumber = rownumber + 1
Loop
%>

</td>
</tr>
<tr>
<%
'Grand Total Routine
lcnt = 0
col1 = 0
If NrGroups > 0 Then
'If any 1 character fields where defined, Grand Totals will appear
For Each WhatCol In rstemp.Fields
If WhatCol.Type = 6 Or WhatCol.Type = 5 Then
sTotal = FormatNumber(CDbl(GrandTotal(lcnt + 1, 0)), 0)
%>

<td bgcolor="<%= bgcolor %>" valign="top" align="right"
style="border-left: medium none; border-right: medium none;
border-top: medium double; border-bottom: medium none"><strong><%= (sTotal)
%></strong>
<%
sTotal = 0
Else
If Len(WhatCol.Name) <> 1 Then
If col1 = 0 Then
sTotal1 = "Grand Total"
col1 = 1
Else
sTotal1 = showblank
End IF
Else
sTotal1 = showblank
End IF
If Len(WhatCol.Name) <> 1 Then
%>
</td>
<td bgcolor="<%= bgcolor %>" valign="top" align="right"
style="border-left: medium none; border-right: medium none;
border-top: medium double; border-bottom: medium none"><strong><%= sTotal1
%></strong>
<%
End IF
End IF
lcnt = lcnt + 1
Next
%>
</td>
</tr>
<%
End IF
Session.Add("rptend", Timer())
Session.Add("rpttime", FormatNumber(CDbl(Session("rptend")) -
CDbl(Session("rptstart")), 1))
rstemp.Close()
rstemp = Nothing
conntemp.Close()
conntemp = Nothing
%>

</table>
<p><small><%
Response.Write("The report ran in " & Session("rpttime") & " second(s)")
%>
</small></td>
</tr>
</table>
<!-------------------------------------------------------------------->

</body>
<script LANGUAGE="VBSCRIPT">
<!--
sub window_onload
updatestatus
end sub
Sub UpdateStatus
Status = "<%= mySQL %>"
end sub

-->
</script>

</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top