Hello,
I want using ASP to call reports (version Crystal Reports 8.5) in a local network. The reports based of a database on a sql-server. With the following code I can access of my reports, but I have this problem: in some reports I use crystal parameter fields, so that the user can set a select parameter, but it is not stringent necessary. (Only) the reports with parameter fields dont get displayed - no parameter field, no report. What can I do?
<%
' Get QS variables
rpttoview = request.querystring("rpt"
viewer = request.querystring("init"
'build full path for report
rpttoview = MID(request.ServerVariables("PATH_TRANSLATED",
1, (LEN(request.ServerVariables("PATH_TRANSLATED")-11)) &
"\myreportdirectory\" & rpttoview & ".rpt"
' build path to database
myConnStr="Driver={SQL
Server};server=myservername;PWD=userpassword;UID=username;
Database=databasename"
set conntemp=server.createobject("adodb.connection"
conntemp.open myConnStr
' 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
' Turn off all Error Message dialogs
Set oGlobalOptions = Session ("oApp".Options
oGlobalOptions.MorePrintEngineErrorMessages = 0
' Open the report
Set session("oRpt" = session("oApp".OpenReport(rpttoview)
' Turn off sepecific report error messages
Set oRptOptions = Session("oRpt".Options
oRptOptions.MorePrintEngineErrorMessages = 0
' now set the table location
'Set oDB = session("oRpt".Database
'For Each oDBTable In oDB.Tables
' oDBTable.Location = conntemp
'Next
' Opening the page engine will cause the data to be read
Set session("oPageEngine" = session("oRpt".PageEngine
' Now decide what viewer to create
Select Case viewer
Case "java"
%>
<applet
ALIGN = LEFT
code=ReportViewer.class
codebase="/viewer/JavaViewer"
id=ReportViewer
width=100%
height=95%>
<param name=ReportName value="rptserver.asp">
</applet>
<%
Case "actx"
%>
<OBJECT ALIGN = LEFT ID="CRViewer" WIDTH=100%
HEIGHT=95%
CLASSID="CLSID:C4847596-972C-11D0-9567-00A0C9273C2A"
CODEBASE="/viewer/activeXViewer/CRViewer.dll#Version=1,2,0,30
">
<PARAM NAME="Report Name" VALUE="rptserver.asp">
<PARAM NAME="Show Group Tree" VALUE= 1>
<PARAM NAME="Show Toolbar" VALUE= 1>
</OBJECT>
<%
Case "html_frame"
response.redirect "htmstart.asp"
Case "html_page"
response.redirect "rptserver.asp"
end select
%>
Thanks for your help.
dzu
I want using ASP to call reports (version Crystal Reports 8.5) in a local network. The reports based of a database on a sql-server. With the following code I can access of my reports, but I have this problem: in some reports I use crystal parameter fields, so that the user can set a select parameter, but it is not stringent necessary. (Only) the reports with parameter fields dont get displayed - no parameter field, no report. What can I do?
<%
' Get QS variables
rpttoview = request.querystring("rpt"
viewer = request.querystring("init"
'build full path for report
rpttoview = MID(request.ServerVariables("PATH_TRANSLATED",
1, (LEN(request.ServerVariables("PATH_TRANSLATED")-11)) &
"\myreportdirectory\" & rpttoview & ".rpt"
' build path to database
myConnStr="Driver={SQL
Server};server=myservername;PWD=userpassword;UID=username;
Database=databasename"
set conntemp=server.createobject("adodb.connection"
conntemp.open myConnStr
' 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
' Turn off all Error Message dialogs
Set oGlobalOptions = Session ("oApp".Options
oGlobalOptions.MorePrintEngineErrorMessages = 0
' Open the report
Set session("oRpt" = session("oApp".OpenReport(rpttoview)
' Turn off sepecific report error messages
Set oRptOptions = Session("oRpt".Options
oRptOptions.MorePrintEngineErrorMessages = 0
' now set the table location
'Set oDB = session("oRpt".Database
'For Each oDBTable In oDB.Tables
' oDBTable.Location = conntemp
'Next
' Opening the page engine will cause the data to be read
Set session("oPageEngine" = session("oRpt".PageEngine
' Now decide what viewer to create
Select Case viewer
Case "java"
%>
<applet
ALIGN = LEFT
code=ReportViewer.class
codebase="/viewer/JavaViewer"
id=ReportViewer
width=100%
height=95%>
<param name=ReportName value="rptserver.asp">
</applet>
<%
Case "actx"
%>
<OBJECT ALIGN = LEFT ID="CRViewer" WIDTH=100%
HEIGHT=95%
CLASSID="CLSID:C4847596-972C-11D0-9567-00A0C9273C2A"
CODEBASE="/viewer/activeXViewer/CRViewer.dll#Version=1,2,0,30
">
<PARAM NAME="Report Name" VALUE="rptserver.asp">
<PARAM NAME="Show Group Tree" VALUE= 1>
<PARAM NAME="Show Toolbar" VALUE= 1>
</OBJECT>
<%
Case "html_frame"
response.redirect "htmstart.asp"
Case "html_page"
response.redirect "rptserver.asp"
end select
%>
Thanks for your help.
dzu