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

How to use Activex Viewer?

Status
Not open for further replies.

srimoti

Programmer
Jul 19, 2002
6
US
Hi guys,

I need to know the procedure to use Activex viewer from an ASP page to display a crystal report. Any documentation or sample code is fine.

Thank you.
 
use Smart Viewer ActiveX.asp which is there in ur segate folder...
 
use Smart Viewer ActiveX.asp which is there in ur segate folder...

Ravi
 
>Any documentation or sample code is fine.

Documentation is non-existant (from Crystal Decisions at least.)

Here is what I've managed to develop so far. Note that some values are constants defined in common_settings, others are in Session Variables, and still others are passed on the URL. Watch for line-wraps on long lines. This represents about a month's worth of work.

Code:
<%@ LANGUAGE=&quot;VBSCRIPT&quot; CodePage=65001 ENABLESESSIONSTATE = True %>
<!-- #include file=&quot;common_settings.asp&quot; -->
<% Dim ReportName, crDatabase, crTable, Table
   const DebuggingEnabled = False '*** Normally False : Set to True to Print Debugging Information ***

   '*** Get Report Name ***
   ReportName=Request(&quot;ReportName&quot;)
   If ( DebuggingEnabled = True ) then Response.Write(&quot;ReportName=&quot;&ReportName&&quot;<br>&quot;):Response.Flush()
%>
<!-- #include file=&quot;AlwaysRequiredSteps.asp&quot; -->
<% '*** Disable Error Handling ***
   On Error Goto 0

   '*** Initialize oApp ***
   If ( Not IsObject (Session(&quot;oApp&quot;)) ) Then Set session(&quot;oApp&quot;) = Server.CreateObject(&quot;CrystalRuntime.Application&quot;) End If

   '*** Initialize oRpt and Open Report ***
   If IsObject(session(&quot;oRpt&quot;)) then Set session(&quot;oRpt&quot;) = Nothing End if    
   Set Session(&quot;oRpt&quot;) = Session(&quot;oApp&quot;).OpenReport(Request.ServerVariables(&quot;APPL_PHYSICAL_PATH&quot;) & Request(&quot;ReportName&quot;), 1)    
   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

   Session(&quot;oRpt&quot;).MorePrintEngineErrorMessages = False
   Session(&quot;oRpt&quot;).EnableParameterPrompting = False
   Session(&quot;oRpt&quot;).DiscardSavedData

   For Each Table In Session(&quot;oRpt&quot;).Database.Tables
      If ( DebuggingEnabled = True ) then Response.Write(&quot;SetLogonInfo for Table &quot; & Table.Name & &quot;<br>&quot;):Response.Flush()
      Table.SetLogonInfo CStr(s_Server), CStr(s_Database), CStr(Session(&quot;request_form_login&quot;)), CStr(Session(&quot;request_form_password&quot;))
   Next

   '*** Disable Error Handling ***
   On Error Goto 0

   '*** Add Filtering ***
   If ( Request(&quot;filter&quot;) <> &quot;&quot; ) Then
      If ( InStrRev(session(&quot;oRpt&quot;).SQLQueryString,&quot;ORDER BY &quot;) > 0 ) Then
         Session(&quot;oRpt&quot;).SQLQueryString = Left(Session(&quot;oRpt&quot;).SQLQueryString,InStrRev(Session(&quot;oRpt&quot;).SQLQueryString,&quot;ORDER BY &quot;)-1) & &quot; WHERE ( &quot; & Request(&quot;filter&quot;)   & &quot; ) &quot; & Mid(Session(&quot;oRpt&quot;).SQLQueryString,InStrRev(Session(&quot;oRpt&quot;).SQLQueryString,&quot;ORDER BY &quot;))
      Else
         Session(&quot;oRpt&quot;).SQLQueryString = Session(&quot;oRpt&quot;).SQLQueryString & &quot; WHERE ( &quot; & Request(&quot;filter&quot;)   & &quot; )&quot;
      End If
      If ( DebuggingEnabled = True ) then Response.Write(&quot;SQLQueryString with <b>Filtering</b>=&quot; & Session(&quot;oRpt&quot;).SQLQueryString & &quot;<br><br>&quot;):Response.Flush()
   End If

   '*** Add Sorting ***
   If ( Request(&quot;order_by&quot;) <> &quot;&quot; ) Then
      If ( InStrRev(Session(&quot;oRpt&quot;).SQLQueryString,&quot;ORDER BY &quot;) > 0 ) Then
         Session(&quot;oRpt&quot;).SQLQueryString = Session(&quot;oRpt&quot;).SQLQueryString & &quot;,&quot;
      Else
         Session(&quot;oRpt&quot;).SQLQueryString = Session(&quot;oRpt&quot;).SQLQueryString & &quot; ORDER BY&quot;
      End If
      Session(&quot;oRpt&quot;).SQLQueryString = Session(&quot;oRpt&quot;).SQLQueryString & &quot; &quot; & Request(&quot;order_by&quot;)
      If ( DebuggingEnabled = True ) then Response.Write(&quot;SQLQueryString with <b>Sorting</b>=&quot; & Session(&quot;oRpt&quot;).SQLQueryString & &quot;<br>&quot;):Response.Flush()
   End If

   Session(&quot;oRpt&quot;).ReadRecords
   If ( Err.Number <> 0 ) Then
      Response.Write &quot;Error Occurred Reading Records: &quot; & Err.Description
      Set Session(&quot;oRpt&quot;) = nothing
      Set Session(&quot;oApp&quot;) = nothing
      Session.Abandon
      Response.End
   Else
      If IsObject(session(&quot;oPageEngine&quot;)) Then Set session(&quot;oPageEngine&quot;) = Nothing End If
      Set Session(&quot;oPageEngine&quot;) = Session(&quot;oRpt&quot;).PageEngine
   End If
%>
<!-- #include file=&quot;MoreRequiredSteps.asp&quot; -->
<% '*** DISPLAY THE REPORT ***
   Server.Transfer(rpt_CR_Report_Viewer)
%>
Good Luck! [thumbsup2]
WindUp
 
Hi,

thank you very much for all your responses (even though its late). It is useful for me. thanks once again

Sri
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top