p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

crystal_reports thread: Re: Crystal reports and ASP


Message #1 by "Bably" <bably@u...> on Tue, 11 Jun 2002 13:01:26
Hi,

I used the below code and always gets an error at line 

Set session ("oApp") = Server.CreateObject("Crystal.CRPE.Application")

saying :
Error Type:
Server object, ASP 0177 (0x800401F3)
Invalid ProgID.

what may be the problem ?? Can anyone help me ..

Thanks in advance
Bably



> <%Languge=VBScript%>
> 
> <%
> 
> dim Conexion, Path, Cadena, Report, CadConexion
> rpttoview = request.querystring("rpt")
> dsn = request.querystring("dsn")
> pwd = request.querystring("pwd")
> 'dsq = request.querystring("dsq")
> uid = request.querystring("uid")
> tbl = request.querystring("tbl")
> sq = request.querystring("sq")
> 
> viewer = "actx"
> Path=Request.ServerVariables("PATH_TRANSLATED")
> While (RIGHT(Path,1)<>"\" AND LEN(Path)<>0)
>     ILEN=LEN(Path)-1
>     Path=LEFT(Path,ILEN)
> Wend
> ' Only create the Crystal Application Object on first time through
> If Not IsObject ( session ("oApp")) Then
> Set session ("oApp") = Server.CreateObject("Crystal.CRPE.Application")
> End If
> Set Conexion=Server.CreateObject("ADODB.connection")
> Info=False;Initial Catalog=INFORMES;Data Source=scaatlas01"
> Conexion.open CadConexion
> 
> 'session ("oApp").LogOnServer "PDSORA7.DLL",cstr(dsn),cstr(dsq),cstr
> (uid),cstr(pwd)
> ' Turn off all Error Message dialogs
> Set oGlobalOptions = Session ("oApp").Options
> oGlobalOptions.MorePrintEngineErrorMessages = 1
> '' Open the report
> If IsObject(session("oRpt")) then
>  Set session("oRpt") = nothing
> End if
> Set session("oRpt") = session("oApp").OpenReport(Path & "reports/" & 
> Report,1)
> ' Turn off sepecific report error messages
> Set oRptOptions = Session("oRpt").Options
> oRptOptions.MorePrintEngineErrorMessages = 1
> ' Opening the page engine will cause the data to be read
> Set session("oPageEngine") = session("oRpt").PageEngine
> 'Session("oRpt").DiscardSavedData
> ' Now decide what viewer to create
> 
> 'On Error Resume Next
> 'Session("oRpt").ReadRecords
> 
> 'If Err.Number <> 0 Then
> '    Response.Write (Err.Description)
> 'Else
> '    Set Session("oPageEngine") = Session("oRpt").PageEngine
> 'End If
> 
> %>
> 
> <HTML>
> <HEAD>
> <TITLE>Seagate Crystal Smart Viewer for ActiveX</TITLE>
> </HEAD>
> <BODY BGCOLOR="C6C6C6" LANGUAGE=VBScript ONLOAD="Page_Initialize">
> 
> <OBJECT ID="CRViewer"
>  CLASSID="CLSID:C4847596-972C-11D0-9567-00A0C9273C2A"
>  WIDTH=100% HEIGHT=95%
>  CODEBASE="/viewers/activeXViewer/activexviewer.cab#Version=2.2.4.37">
> <param name="DisplayGroupTree" value="-1">
> <param name="DisplayToolbar" value="-1">
> <param name="EnableGroupTree" value="-1">
> <param name="EnableNavigationControls" value="-1">
> <param name="EnableStopButton" value="-1">
> <param name="EnablePrintButton" value="-1">
> <param name="EnableZoomControl" value="-1">
> <param name="EnableCloseButton" value="-1">
> <param name="EnableProgressControl" value="-1">
> <param name="EnableSearchControl" value="-1">
> <param name="EnableRefreshButton" value="-1">
> <param name="EnableDrillDown" value="-1">
> <param name="EnableAnimationControl" value="-1">
> <param name="EnableSelectExpertButton" value="0">
> <param name="EnableToolbar" value="-1">
> <param name="DisplayBorder" value="-1">
> <param name="DisplayTabs" value="-1">
> <param name="DisplayBackgroundEdge" value="-1">
> <param name="SelectionFormula" value>
> <param name="EnablePopupMenu" value="-1">
> <param name="EnableExportButton" value="-1">
> <param name="EnableSearchExpertButton" value="0">
> <param name="EnableHelpButton" value="0">
> </OBJECT>
> 
> <SCRIPT LANGUAGE="VBScript">
> <!--
> Sub Page_Initialize
>  'On Error Resume Next
>  Dim webBroker
>  Set webBroker = CreateObject("WebReportBroker.WebReportBroker")
>  if ScriptEngineMajorVersion < 2 then
>   window.alert "IE 3.02 users on NT4 need to get the latest version of 
> VBScript or install IE 4.01 SP1. IE 3.02 users on Win95 need DCOM95 and 
> latest version of VBScript, or install IE 4.01 SP1. These files are 
> available at Microsoft's web site."
>   'CRViewer.ReportName = Location.Protocol + "//" + 
> Location.Host+"/rptserver.asp"
>   CRViewer.ReportName = Location.Protocol + "//" + Location.Host+  
> + "/rptserver.asp"
>  else
>   Dim webSource
>   Set webSource = CreateObject("WebReportSource.WebReportSource")
>   webSource.ReportSource = webBroker
>   webSource.URL = Location.Protocol + "//" + Location.Host 
> + "/rptserver.asp"
>   webSource.PromptOnRefresh = True
>   CRViewer.ReportSource = webSource
>  end if
>  CRViewer.ViewReport
> End Sub
> -->
> </SCRIPT>
> 
> </BODY>
> </HTML>
> 
> 
> It's working on 7 crystal version, but not so good on 8.5. So if you 
guess 
> the good way, please write me to mariapequeno@y...
> 
> And if you know to use stored procedures into this code tell it also to 
me.
> 
> Thanks and good luck,
> Maria

  Return to Index