Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem in closing the connection - blank sub report

Status
Not open for further replies.

natncm70

MIS
Jan 16, 2002
66
0
0
IN
Hello,
I am having one main report and two sub reports. If I close the connection in the last line of the ASP page. it is dsiplaying only main report. If I am not closing the database connection. it is displaying all the reports. This is my problem.
This is my code.

<!-- #include file=&quot;check.inc&quot; -->
<!-- #include file=&quot;getconnection.inc&quot; -->


<%

Dim rs,strsql, strDSN, strUser, strPass, strcon, user, pass,strbranch, strdate, strcommand , strfor, strCust_tot,strCust_per

set rs = server.CreateObject(&quot;ADODB.Recordset&quot;)
set rs1 = server.CreateObject(&quot;ADODB.Recordset&quot;)
set rs2 = server.CreateObject(&quot;ADODB.Recordset&quot;)
set rs3 = server.CreateObject(&quot;ADODB.Recordset&quot;)
set rs4 = server.CreateObject(&quot;ADODB.Recordset&quot;)
'set conn = server.CreateObject(&quot;ADODB.Connection&quot;)

strsql = &quot;sel 'all',upper(product_desc), customer_nbr, region_desc, upper(channel_desc), sdate, sum(customer_nbr) over (partition by channel_desc rows between unbounded preceding and unbounded following) from DP_VEDW.MIS_customer_analysis where channel_desc in ('&quot;& branch_name &&quot;' ) and sdate='&quot;&str_sdate&&quot;' &quot;

rs.open strsql,conn
'close the recordset
if rs.EOF or rs.BOF then
Response.Write &quot;Please Select Another Date.<BR><BR><a href='get_details_report5.asp?page=report5'>Click here to go Back</a>&quot;
else
dim var
Dim objApp
Dim objRpt
basePath = Request.ServerVariables(&quot;PATH_TRANSLATED&quot;)
While (Right(basePath, 1) <> &quot;\&quot; And Len(basePath) <> 0)
iLen = Len(basePath) - 1
basePath = Left(basePath, iLen)
Wend
baseVirtualPath = Request.ServerVariables(&quot;PATH_INFO&quot;)
While (Right(baseVirtualPath, 1) <> &quot;/&quot; And Len(baseVirtualPath) <> 0)
iLen = Len(baseVirtualPath) - 1
baseVirtualPath = Left(baseVirtualPath, iLen)
Wend
If Not IsObject(session(&quot;oApp&quot;)) Then
Set session(&quot;oApp&quot;) = Server.CreateObject(&quot;CrystalRuntime.Application&quot;)
If Not IsObject(session(&quot;oApp&quot;)) Then
response.write &quot;Error: Could not instantiate the Crystal Reports automation server. Please check to see that Crystal Reports or ReCrystallize has been properly installed on the web server PC. See the ReCrystallize Pro Getting Started guide for more information.&quot;
response.end
End If
End If

If IsObject(session(&quot;oRpt&quot;)) then
set session(&quot;oRpt&quot;) = nothing
End If

If autofilespec <> &quot;&quot; Then
reportFileName = autofilespec
Else
reportFileName = &quot;Branch_wise_Customer_v1.rpt&quot;

End If
strTitle = &quot;As On : &quot; & str_sdate
mgrFlag = &quot;False&quot;
corpFlag = &quot;False&quot;
Set session(&quot;oRpt&quot;) = session(&quot;oApp&quot;).OpenReport(basepath & reportFileName, 1)
session(&quot;oRpt&quot;).FormulaFields.GetItemByName(&quot;AS_ON_DATE&quot;).Text = Chr(34) & strTitle & Chr(34)
session(&quot;oRpt&quot;).FormulaFields.GetItemByName(&quot;Cust_per&quot;).Text = Chr(34) & strCust_per & Chr(34)
session(&quot;oRpt&quot;).FormulaFields.GetItemByName(&quot;Cust_tot&quot;).Text = Chr(34) & strCust_tot & Chr(34)
If Err.Number <> 0 Then
Response.Write &quot;Error Occurred creating Report Object: &quot; & Err.Description
Set Session(&quot;oRpt&quot;) = Nothing
Set Session(&quot;oApp&quot;) = Nothing
Session.Abandon
Response.End
End If
set crtable = session(&quot;oRpt&quot;).Database.Tables.Item(1)
crtable.SetLogonInfo &quot;mis&quot;,&quot;&quot;, cstr(struser), cstr(strpass)
crtable.SetPrivateData 3, rs

if Request.Form(&quot;user_type&quot;) = &quot;corporate&quot; and Request.Form(&quot;summary_rpt&quot;) = &quot;on&quot; then
Set CRSubreports = session(&quot;oRpt&quot;).OpenSubreport(&quot;sub_rpt_2_branch_wise_customer&quot;)
corpFlag = &quot;True&quot;


'Create the ADO Database Connection:
'STRSQL = &quot;select REGION,SDATE,CURRENT_C,CURRENT_T,SAVINGS_C,SAVINGS_T,TERM_C,TERM_T,CUMMULATIVE_C,CUMMLATIVE_T,LIQUID_C,LIQUID_T,RECURR_C,RECURR_T,NRNR_C,NRNR_T,NRE_C,NRE_T,CD_C,CD_T,SENIOR_C,SENIOR_T from DP_MIS.deposit_type_wise where branch in ('&quot;& branch_name &&quot;' ) and sdate='&quot;&str_sdate&&quot;' group by 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22&quot;
strsql = &quot; sel upper(product_desc), sum(customer_nbr) from DP_VEDW.MIS_customer_analysis where sdate='&quot;&str_sdate&&quot;' group by 1 &quot;
rs4.open strsql,conn

Set Database3 = CRSubreports.Database
set Tables3 = Database3.Tables
set Table1s1 = Tables3.Item(1)
CRSubreports.DiscardSavedData
Table1s1.SetPrivateData 3, rs4

'CRSubreports.FormulaFields.GetItemByName(&quot;AS_ON_DATE&quot;).Text = Chr(34) & strTitle & Chr(34)
end if
'rs4.close
if ( (Request.Form(&quot;user_type&quot;) = &quot;region&quot; and Request.Form(&quot;summary_rpt&quot;) = &quot;on&quot;) OR (Request.Form(&quot;user_type&quot;) = &quot;corporate&quot;) ) then
Set CRSubreports = session(&quot;oRpt&quot;).OpenSubreport(&quot;sub_rpt_branch_wise_customer&quot;)
mgrFlag = &quot;True&quot;
'Create the ADO Database Connection:
'STRSQL = &quot;select REGION,SDATE,CURRENT_C,CURRENT_T,SAVINGS_C,SAVINGS_T,TERM_C,TERM_T,CUMMULATIVE_C,CUMMLATIVE_T,LIQUID_C,LIQUID_T,RECURR_C,RECURR_T,NRNR_C,NRNR_T,NRE_C,NRE_T,CD_C,CD_T,SENIOR_C,SENIOR_T from DP_MIS.deposit_type_wise where branch in ('&quot;& branch_name &&quot;' ) and sdate='&quot;&str_sdate&&quot;' group by 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22&quot;
strsql = &quot; sel upper(product_desc), customer_nbr, region_desc, sdate, sum(customer_nbr) over (partition by region_desc rows between unbounded preceding and unbounded following) from DP_VEDW.MIS_customer_analysis where channel_desc in ('&quot;& branch_name &&quot;' ) and sdate='&quot;&str_sdate&&quot;' &quot;
rs3.open strsql,conn
Set Database2 = CRSubreports.Database
set Tables2 = Database2.Tables
set Table1s = Tables2.Item(1)
CRSubreports.DiscardSavedData
Table1s.SetPrivateData 3, rs3
session(&quot;oRpt&quot;).OpenSubreport(&quot;sub_rpt_branch_wise_customer&quot;).readrecords
CRSubreports.FormulaFields.GetItemByName(&quot;AS_ON_DATE&quot;).Text = Chr(34) & strTitle & Chr(34)
end if

session(&quot;oRpt&quot;).FormulaFields.GetItemByName(&quot;mgr_flag&quot;).Text = Chr(34) & mgrFlag & Chr(34)
session(&quot;oRpt&quot;).FormulaFields.GetItemByName(&quot;corp_flag&quot;).Text = Chr(34) & corpFlag & Chr(34)

If IsObject (session(&quot;oPageEngine&quot;)) Then
set session(&quot;oPageEngine&quot;) = nothing
End If
session(&quot;oRpt&quot;).ReadRecords
set session(&quot;oPageEngine&quot;) = session(&quot;oRpt&quot;).PageEngine
set session(&quot;oRpt&quot;) = nothing

%><BODY BGCOLOR=C6C6C6 LANGUAGE=VBScript ONLOAD=&quot;Page_Initialize&quot;>
<TABLE cellSpacing=1 cellPadding=1 width=750 align=center border=0>

<TR>
<TD>
<P align=center><A href=&quot;home.asp&quot;><STRONG><FONT face=Verdana
size=1>Home</FONT></STRONG></A></P></TD>
<TD>
<P align=center><A href=&quot;customer_analysis.asp&quot;><STRONG><FONT face=Verdana
size=1>Report Group Page</FONT></STRONG></A></P></TD>
<TD>
<P align=center><A href=&quot;get_details_report5.asp?page=report5&quot; ><STRONG><FONT face=Verdana
size=1>Report Input Form</FONT></STRONG></A></P></TD>
<TD>
<P align=center><A href=&quot;logout.asp&quot;><STRONG><FONT
face=Verdana size=1>Logout</FONT></STRONG></A></P></TD></TR></TABLE>
<object id=&quot;CRViewer&quot;
classid=&quot;CLSID:C4847596-972C-11D0-9567-00A0C9273C2A&quot;
width=100% height=100%
codebase=&quot;/viewer/activeXViewer/activexviewer.cab#Version=1,0,0,0&quot;>
<param name=&quot;EnableRefreshButton&quot; value=0>
<param name=&quot;EnableExportButton&quot; value=1>
<param name=&quot;EnablePrintButton&quot; value=1>
<% if ( Request.Form(&quot;user_type&quot;) = &quot;normal&quot;) then %>
<param name=&quot;EnableGroupTree&quot; value=0>
<param name=&quot;DisplayGroupTree&quot; value=0>
<param name=&quot;EnableDrillDown&quot; value=0>
<%else%>
<param name=&quot;EnableGroupTree&quot; value=1>
<param name=&quot;DisplayGroupTree&quot; value=1>
<param name=&quot;EnableDrillDown&quot; value=1>
<%end if%>

<param name=&quot;EnableAnimationControl&quot; value=1>
<param name=&quot;EnableZoomControl&quot; value=1>
<param name=&quot;EnableSearchControl&quot; value=1>
<param name=&quot;DisplayToolbar&quot; value=1>
<param name=&quot;EnableProgressControl&quot; value=1>
<param name=&quot;EnableStopButton&quot; value=1>
<param name=&quot;EnableCloseButton&quot; value=1>
<param name=&quot;EnableNavigationControls&quot; value=1>
<param name=&quot;PromptOnRefresh&quot; value=0>
<param name=&quot;EnablePopupMenu&quot; value=1>
<param name=&quot;DisplayBackgroundEdge&quot; value=0>
<param name=&quot;DisplayBorder&quot; value=0>
<param name=&quot;DisplayTabs&quot; value=0>
</object>
<SCRIPT LANGUAGE=&quot;VBScript&quot;>
<!--
zoomTimer = window.setInterval(&quot;setZoom&quot;,250)

Sub setZoom()
if not CRViewer.IsBusy then
window.clearInterval(zoomTimer)
CRViewer.Zoom(100)
end if
End Sub
Sub Page_Initialize
On Error Resume Next
Dim webBroker
Set webBroker = CreateObject(&quot;WebReportBroker.WebReportBroker&quot;)
if ScriptEngineMajorVersion < 2 then
window.alert &quot;Internet Explorer 3.02 users running Windows NT 4 should get the latest version of VBScript or install IE 4.01 SP1. IE 3.02 users running Windows 95 need DCOM95 and the latest version of VBScript, or install IE 4.01 SP1. These files are available at Microsoft's web site.&quot;
CRViewer.ReportName = Location.Protocol + &quot;//&quot; + Location.Host + <% response.write( chr(34) & baseVirtualPath & chr(34)) %> + &quot;rptserver.asp&quot;
else
Dim webSource
Set webSource = CreateObject(&quot;WebReportSource.WebReportSource&quot;)
webSource.ReportSource = webBroker
webSource.URL = Location.Protocol + &quot;//&quot; + Location.Host + <% response.write( chr(34) & baseVirtualPath & chr(34)) %> + &quot;rptserver.asp&quot;
webSource.PromptOnRefresh = False
CRViewer.ReportSource = webSource
end if
CRViewer.ViewReport

End Sub
-->

</SCRIPT>

</body><%end if%>
<%

rs.close
conn.close %>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top