Link to home
Start Free TrialLog in
Avatar of srafi78
srafi78Flag for United States of America

asked on

Crystal Reports and ASP "a Trappable Error occurred in external object Script cannot continue" Urgent Help Required

Hi, I was trying to develop an application using ASP for Crystal Reports 9, to view the reports already created in the Crystal Reports Designer. The Database I am using is Oracle 9i and I have the oracle client installed for this database on my Dev machine. I have written the following code from the code examples supplied by Business Objects. When I try to execute the following script I get the error as
 Active Server Pages, ASP 0115 (0x80004005)
A trappable error (E06D7363) occurred in an external object. The script cannot continue running.
/Test123/TestReports.asp

When I try to debug the code I am stalled at the Line where I declare the database connection properties.

Is the code right? I have not developed this type of application before. I need urgent help as the Project is due to Go Live in the first week of New Year.

Thanks in Advance
SR

<%

'Create the Application object

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

'Create Report Object

reportname = "C:\ReportDesignASP\SimpleSetLogonInfo\rptTest1.rpt"

If IsObject(session("oRpt")) then
      Set session("oRpt") = nothing
End If
Set session("oRpt") = session("oApp").OpenReport(reportname,1)

'Disable error prompts on webserver
session("oRpt").EnableParameterPrompting = False

'Log On to report database connection

session("oRpt").Database.Tables(1).ConnectionProperties("Server") = "ORADB"
session("oRpt").Database.Tables(1).ConnectionProperties("User Id") = "xxxx"
session("oRpt").Database.Tables(1).ConnectionProperties("Password") = "xxxx"

session("oRpt").DiscardSavedDate

on Error Resume Next
session("oRpt").ReadRecords
If Err.Number<>0 THEN
Response.Write ("A server error occured when trying to access the datasource")
End If

If IsObject(session("oPageEngine")) Then
      Set session("oPageEngine") = Nothing
End If
Set session("oPageEngine") = session("oRpt").PageEngine

%>

<!-- #include file="ActiveXPluginViewer.asp" -->
ASKER CERTIFIED SOLUTION
Avatar of GJParker
GJParker
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of srafi78

ASKER


Hi Gary,
 I tried the code you supplied and was able to move forward but now I just get a grey screen with a small mark at the top left of the screen. The modified code is


<%

'Create the Application object

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

'Create Report Object

reportname = "C:\ReportDesignASP\SimpleSetLogonInfo\rptTest1.rpt"

If IsObject(session("oRpt")) then
      Set session("oRpt") = nothing
End If
Set session("oRpt") = session("oApp").OpenReport(reportname,1)

'Disable error prompts on webserver
session("oRpt").EnableParameterPrompting = False

'Log On to report database connection

'Creat a tables collection
Set crTableCollection = Session("oRpt").Database.Tables

'Loop through the tables and assign log on info
For Each crTable in crTableCollection

crtable.ConnectionProperties.Item("DSN") = "DSN"
crtable.ConnectionProperties.Item("User ID") = "User"
crtable.ConnectionProperties.Item("Password") = "Pass"
if not crtable.TestConnectivity then
    response.write "Warning:  Unable to connect to data source using the following information.<BR><BR>"
    response.write "Server / ODBC data source: " & crtable.ConnectionProperties.Item("DSN") & "<BR>"
    response.write "Database / Table: " & crtable.ConnectionProperties.Item("Database") & "<BR>"
    response.write "User Name: " & crtable.ConnectionProperties.Item("User ID") & "<BR>"
    response.write "Please verify the database user password in this ASP file.<BR><BR>"
end if

Next

session("oRpt").DiscardSavedData

On Error Resume Next

session("oRpt").ReadRecords
If Err.Number <> 0 Then
  Response.Write "Error Occurred Reading Records: " & 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
%>

<!-- #include file="ActiveXPluginViewer.asp" -->

How can I get my report to show up in the browser?

 Also, can you brief me on how to pass parameters. I have set three parameters for searching through the records in the reports. The records can be searched by Customer ID or the lastname( last name can be accompanied by the first name(optional)?

Thank you in advance.
SR
if the samll mark is the Red x this means that the viewer has not been downloaded to the client machine.

There are many reason why this occurs you will need search the BO website and check the knowledge base for documents relating to yor specific setup.

Go to http://support.businessobjects.com/search/advsearch.asp?q= and enter Red x as the search criteria.

Here is the info for passing parameter values to the report

'The following section shows setting single valued parameters of various data types.
Session("oRpt").ParameterFields.GetItemByName("ExampleStringParameter").AddCurrentValue(CStr("I am a string"))
Session("oRpt").ParameterFields.GetItemByName("ExampleNumberParameter").AddCurrentValue(CDbl("12345"))
Session("oRpt").ParameterFields.GetItemByName("ExampleBooleanParameter").AddCurrentValue(CBool("True"))
Session("oRpt").ParameterFields.GetItemByName("ExampleCurrencyParameter").AddCurrentValue(CDbl("10.3273"))
Session("oRpt").ParameterFields.GetItemByName("ExampleDateParameter").AddCurrentValue(CDate("2001/Jan/02"))
Session("oRpt").ParameterFields.GetItemByName("ExampleTimeParameter").AddCurrentValue(CDate("3:45:00 PM"))
Session("oRpt").ParameterFields.GetItemByName("ExampleDateTimeParameter").AddCurrentValue(CDate("2001/Jan/02 3:45:00 PM"))

'This section demonstrates the enabling of multiple values for a parameter and then setting
'a number of different values for that single parameter.
session("oRpt").ParameterFields.GetItemByName("ExampleMultiValuedStringParameter").EnableMultipleValues = 1
session("oRpt").ParameterFields.GetItemByName("ExampleMultiValuedStringParameter").AddCurrentValue(CStr("Anne"))
session("oRpt").ParameterFields.GetItemByName("ExampleMultiValuedStringParameter").AddCurrentValue(CStr("Nancy"))
session("oRpt").ParameterFields.GetItemByName("ExampleMultiValuedStringParameter").AddCurrentValue(CStr("Laura"))
session("oRpt").ParameterFields.GetItemByName("ExampleMultiValuedStringParameter").AddCurrentValue(CStr("Justin"))
session("oRpt").ParameterFields.GetItemByName("ExampleMultiValuedStringParameter").AddCurrentValue(CStr("Margaret"))
session("oRpt").ParameterFields.GetItemByName("ExampleMultiValuedStringParameter").AddCurrentValue(CStr("Steven"))
session("oRpt").ParameterFields.GetItemByName("ExampleMultiValuedStringParameter").AddCurrentValue(CStr("Albert"))

'This section shows enabling a parameter to accept a ranged parameter.
'The first line sets the DiscreetOrRangeKind to 1. For Ranged parameters the constant is 1.
'The second line uses the AddCurrentRange method which takes three arguments.
' AddCurrentRange LowerBoundValue, UpperBoundValue, CRRangeInfoConstant
'The CRRangeInfoConstant of 3 indicates that the range should include values greater than or equal to
'the lower bound and less than or equal to the upper bound.

session("oRpt").ParameterFields.GetItemByName("ExampleRangedNumberParameter").DiscreteOrRangeKind = 1
session("oRpt").ParameterFields.GetItemByName("ExampleRangedNumberParameter").AddCurrentRange CDbl("5"),CDbl("10"),CDbl("3")


Here is code to utilise the report parameter collection

set session("ParamCollection") = Session("oRpt").Parameterfields

set Param1 =  session("ParamCollection").Item(1)
Call Param1.SetCurrentValue (CDbl(ParamValue1))

set Param2 =  session("ParamCollection").Item(2)
Call Param2.SetCurrentValue (Cstr(LastName))

set Param3 =  session("ParamCollection").Item(3)
Call Param3.SetCurrentValue (Cstr(FirstName))

Gary
Avatar of srafi78

ASKER

Thanks Gary, I really appreciate your help. You deserve the full score with an A!
SR
SR

If you can get the big cheeses to stump up the meager fee, there is a 3rd party utily called Recrystallize which creates the ASP pages for you, including any database logons, paramaters , viewer buttons and resizing etc. I think it's well worth the money

You can find out more at http://www.recrystallize.com/

Gary