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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TTX file, ASP & subreport

Status
Not open for further replies.

6064id

IS-IT--Management
Apr 22, 2002
5
IL
Hi
I am searching for few days now a way to pass to the subreport recordset. I have an example of a main report getting recordset via ado connection but it is not enough. I would really appreciate if some one out there could give an example of who to pass 1st recordset to main report and 2nd recordset to subreport and all in ASP NOT !!!VB!!!

Thanks in advance to all
 
I had the same issue and developed the code below which seems to work for me. This is using procedure in SQLServer.

NOTE: I've pulled out most of the normal ASP code to save space.

Code:
<%@ LANGUAGE=&quot;VBSCRIPT&quot; %>
<%
Set oConn = server.CreateObject(&quot;ADODB.Connection&quot;)
oConn.Open session(&quot;oSession&quot;)

Set oCmd = server.CreateObject(&quot;ADODB.Command&quot;)
Set session(&quot;oRS&quot;) = server.CreateObject(&quot;ADODB.RecordSet&quot;)

'set the report name
reportname = &quot;acme.rpt&quot;
Set session(&quot;oRpt&quot;) = session(&quot;oApp&quot;).OpenReport(path & reportname, 1)

sSQL = &quot;exec acme_get_results&quot;

' Set ADO Connection properties
oCmd.ActiveConnection = oConn
oCmd.CommandTimeout = 10000
oCmd.CommandText = sSQL
oCmd.CommandType = 1 

' Execute the command and retrieve the record set
Set session(&quot;oRS&quot;) = oCmd.Execute 

' Associate the record set with the reports database tables
Set oRptTable = session(&quot;oRpt&quot;).Database.Tables.Item(1)
oRptTable.SetPrivateData 3, session(&quot;oRS&quot;)
		
' Cleanup any session variables
Set oCmd = Nothing
Set session(&quot;oRS&quot;) = Nothing

' ... set parameters if applicable

' Open and define the datasource for the subreport
Set CRSubReports = session(&quot;oRpt&quot;).OpenSubreport(&quot;acmesubreport.rpt&quot;)

Set oCmd = server.CreateObject(&quot;ADODB.Command&quot;)
Set session(&quot;oRS&quot;) = server.CreateObject(&quot;ADODB.RecordSet&quot;)
sSQL = &quot;exec acme_get_details&quot;

' Set ADO Connection properties
oCmd.ActiveConnection = oConn
oCmd.CommandTimeout = 10000
oCmd.CommandText = sSQL
oCmd.CommandType = 1 

' Execute the command and retrieve the record set
Set session(&quot;oRS&quot;) = oCmd.Execute 

' Associate the record set with the reports database tables
CRSubReports.MorePrintEngineErrorMessages = False
CRSubReports.EnableParameterPrompting = False
CRSubReports.DiscardSavedData

Set Database2 = CRSubReports.Database
Set Tables2 = Database2.Tables
Set Table2 = Tables2.Item(1)
Table2.SetPrivateData 3, session(&quot;oRS&quot;)

' Cleanup any session variables???
Set oCmd = Nothing
Set session(&quot;oRS&quot;) = Nothing
Set oConn = Nothing
%>

	<!-- #INCLUDE FILE=&quot;inc/page_engine.inc&quot;  -->                                                                      
	<!-- #include file=&quot;SmartViewerActiveX.asp&quot; -->

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top