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

Server Failed To Create Crystal Runtime Object

Status
Not open for further replies.

Glazieyes

Programmer
Jun 18, 2004
8
GB
Hi,

I am using ASP to display a Crystal Report (version 10). Here is my code :


-----------------------------------------------------------
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR">
</HEAD>
<body ONUNLOAD="CallDestroy();" leftmargin=0 topmargin=0 rightmargin=0 bottommargin=0>
<OBJECT ID="CRViewer" CLASSID="CLSID:A1B8A30B-8AAA-4a3e-8869-1DA509E8A011" WIDTH=100% HEIGHT=99%
CODEBASE="/crystalreportviewers10/ActiveXControls/ActiveXViewer.cab#Version=10,0,0,533" VIEWASTEXT>
<PARAM NAME="EnableRefreshButton" VALUE=1>
<PARAM NAME="EnableGroupTree" VALUE=1>
<PARAM NAME="DisplayGroupTree" VALUE=1>
<PARAM NAME="EnablePrintButton" VALUE=1>
<PARAM NAME="EnableExportButton" VALUE=1>
<PARAM NAME="EnableDrillDown" VALUE=1>
<PARAM NAME="EnableSearchControl" VALUE=1>
<PARAM NAME="EnableAnimationControl" VALUE=1>
<PARAM NAME="EnableZoomControl" VALUE=1>
</OBJECT>
<SCRIPT LANGUAGE="VBScript">
<!--
Sub Window_Onload
On Error Resume Next
Dim webBroker
//Set webBroker = CreateObject("CrystalReports10.WebReportBroker.1")
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."
else
Dim webSource
//Set webSource = CreateObject("CrystalReports10.WebReportSource.1")
Set webSource = CreateObject("WebReportSource.WebReportSource")
webSource.ReportSource = webBroker
webSource.URL = "RDCrptserver10.asp"
webSource.PromptOnRefresh = True
CRViewer.ReportSource = webSource
end if
CRViewer.ViewReport
End Sub
-->
</SCRIPT>

<script language="javascript">
function CallDestroy()
{
window.open("Cleanup.asp");
}
</script>

<%
reportname = "TestCrystal.rpt"

If Not IsObject(session("oApp")) Then
Set session("oApp") = Server.CreateObject("CrystalRuntime.Application.10")
End If

Path = Request.ServerVariables("PATH_TRANSLATED")
While (Right(Path, 1) <> "\" And Len(Path) <> 0)
iLen = Len(Path) - 1
Path = Left(Path, iLen)
Wend

If IsObject(session("oRpt")) then
Set session("oRpt") = nothing
End if

On error resume next

Response.Write(Path & reportname)
Set session("oRpt") = session("oApp").OpenReport(Path & reportname, 1)

If Err.Number <> 0 Then
Response.Write "Error Occurred creating Report Object: " & Err.Description
Set Session("oRpt") = nothing
Set Session("oApp") = nothing
Session.Abandon
Response.End
End If

session("oRpt").MorePrintEngineErrorMessages = False
session("oRpt").EnableParameterPrompting = False
session("oRpt").DiscardSavedData

'CRViewer.ViewReport
session("oRpt").ReadRecords
'session("oRpt").ViewReport
If Err.Number <> 0 Then
Response.Write "Error Occurred Reading Records: " & Err.Number & " " & Err.Description
Set Session("oRpt") = nothing
Set Session("oApp") = nothing
Session.Abandon
Response.End
Else
If IsObject(session("oPageEngine")) Then
set session("oPageEngine") = nothing
End If
set session("oPageEngine") = session("oRpt").PageEngine
End If
%>
</BODY>
</HTML>
-----------------------------------------------------------


My machine has Crystal Report v10 installed and when the code runs it displays the Crystal Viewer and the following error:

Server object error 'ASP 0177 : 800401f3'

Server.CreateObject Failed

on this line of code:

Set session("oApp") = Server.CreateObject ("CrystalRuntime.Application.10").

As crystal is not installed on the server I think it may be a dll issue. The only Crystal dll which is installed on the server is MSWCRUN.dll.

I have ActiveX Viewers installed on my local machine :

CRVIEWER.all
CSELEXPT.ocx
NPSSVIEW.dll
SINFORS.dll
SVIEWHLP.dll
SWEBRS.dll
XQVIEWER.dll


Do these need to be registered on the server also?

Are there any other dll's that need to be registered on my local machine / the server?

Please help me, my pretty little head is melted.
 
I actually ran your web page successfully. i created a report that uses odbc to sql server but i need to add login parameters to your code. I believe your problem is needing the runtime files on your server. To make things easier just install crystal reports on the web server to get the RDC. You may need the developer edition for this but i'm not sure. I believe there is a way to copy over and register the runtime files but i've never been able to do it successfully. There is a help file called runtime.chm I believe that may help you if you try to do it that way.
 
Thanks very much for the quick replies.

I'm not able/allowed to install Crystal on our servers but I've had a look at the runtime.chm help file that Jagg suggested and it details how and what runtime dll's to manually install.

If it works I'll detail it step by step for other users because finding specific, reliable info on this is like looking for a needle in a haystack!

Thanks again, feeling the love! [gorgeous]

Glazieyes
 
Hi,

I registered the appropriate dll's on the server according to the runtime.chm.

I'm getting a different error now on the - session("oRpt").ReadRecords line.

I think it is to do with logon parameters as the database I am trying to access is password protected.

Does anyone know how/where to include logon parameters in the code above?
 
Since you didn't post your database connection and assuming you're using ODBC to SQL server just after your if/end if code checking for errors add something like this:

'Create a reference to the tables collection of the main report
Set mainReportTableCollection = Session("oRpt").Database.Tables
For Each mnTable in mainReportTableCollection
With mnTable.ConnectionProperties
.Item("user ID") = "your user"
.Item("Password") = "your password"
End With
If mnTable.TestConnectivity then
Else
Response.Write "Database Not Connected <BR>"
Response.Write "Contact System Administrator"
Response.End
End if
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top