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

Does anyone has an example of crystal reports & ASP

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I use this code an always get error 424 object required

<%@ Language=VBScript %>
<HTML>
<HEAD>
</HEAD>
<BODY>
<sCRIPT LANGUAGE=&quot;VBScript&quot; RUNAT=&quot;Server&quot;>
ReportName = MID(request.ServerVariables(&quot;PATH_TRANSLATED&quot;), 1, (LEN(request.ServerVariables(&quot;PATH_TRANSLATED&quot;))-18)) & &quot;moe_gradsurvey_04_deg_poly_test.rpt&quot;
On Error Resume Next

If Not IsObject ( session(&quot;oApp&quot;) ) Then
Set session (&quot;oApp&quot;) = Server.CreateObject(&quot;CrystalRuntime.Application&quot;)
End If
Call session(&quot;oApp&quot;).SetMorePrintEngineErrorMessages(0)
Call session(&quot;oApp&quot;).SetMatchLogonInfo(1)

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(Reportname,1)
Session(&quot;oRpt&quot;).MorePrintEngineErrorMessages = 0
session(&quot;oRpt&quot;).DiscardSavedData
'for testing only
set session(&quot;unitcode&quot;)=&quot;Pohjois-Karjalan ammattikorkeakoulu&quot;

'Select Unit Code
session(&quot;oRpt&quot;).ParameterFields(1).AddCurrentValue(session(&quot;unitcode&quot;))


'select Degree
session(&quot;oRpt&quot;).ParameterFields(2).AddCurrentValue(Request.Form(&quot;degreelist&quot;))

'select startdate
'session(&quot;oRpt&quot;).ParameterFields(3).AddCurrentValue(date(Request.Form(&quot;startdate&quot;)))

'select enddate
'session(&quot;oRpt&quot;).ParameterFields(4).AddCurrentValue(date(Request.Form(&quot;enddate&quot;)))
If Err.Number <> 0 Then
Response.Write &quot;An Error has occured. Please check the ASP page.<BR>&quot;
Response.Write &quot;Error &quot; & Err.number & &quot; &quot; & Err.description
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
</SCRIPT>
<OBJECT ID=&quot;CRViewer1&quot;
CLASSID=&quot;CLSID:C4847596-972C-11D0-9567-00A0C9273C2A&quot;
WIDTH=100%
HEIGHT=100%
CODEBASE=&quot;/viewer/activeXViewer/activexviewer.cab#Version=8,0,0,371&quot;>
' Customize the Report Viewer to turn on/off the group tree
If Request.Form(&quot;chkGroupTree&quot;) = &quot;ON&quot; Then<param name=&quot;DisplayGroupTree&quot; value=1>Else<param name=&quot;DisplayGroupTree&quot; value=0>End If<param name=&quot;EnableRefreshButton&quot; value=1><param name=&quot;EnablePrintButton&quot; value=1><param name=&quot;EnableExportButton&quot; value=1><param name=&quot;EnableSearchControl&quot; value=1><param name=&quot;EnableDrillDown&quot; value=1><param name=&quot;EnableAnimationControl&quot; value=1><param name=&quot;EnableZoomControl&quot; value=1></OBJECT>

<SCRIPT LANGUAGE=&quot;VBScript&quot;>
Call Page_Initialize

Sub Page_Initialize
On Error Resume Next
Dim WebBroker1
Set WebBroker1 = CreateObject(&quot;WebReportBroker.WebReportBroker&quot;)
Call GetURL(URL)
if ScriptEngineMajorVersion < 2 then
window.alert &quot;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.&quot;
CRViewer1.ReportName = URL + &quot;rptserver.asp&quot;
else
Dim WebSource1
Set WebSource1 = CreateObject(&quot;WebReportSource.WebReportSource&quot;)
WebSource1.ReportSource = WebBroker1
WebSource1.URL = URL + &quot;rptserver.asp&quot;
WebSource1.PromptOnRefresh = true
CRViewer1.ReportSource = WebSource1
end if
CRViewer1.ViewReport
End Sub

Sub GetURL(ByRef URL)
HREF = Location.Href
URL= &quot;&quot;
nPos = InStr(HREF, &quot;/&quot;)
While (nPos > 0)
URL = URL & Left( HREF, nPos )
HREF = Mid(HREF, nPos + 1)
nPos = InStr(HREF, &quot;/&quot;)
Wend
End Sub
</SCRIPT>


</BODY>
</HTML>
 
Did you look for examples on the CD website, or in the developers help? Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
This is the code I use to call my report, although my app is ColdFusion based rather than ASP, none of this code used is either ;)


<!---uses crystal reports version 8 --->
<OBJECT ID=&quot;CRViewer&quot;
CLASSID=&quot;CLSID:C4847596-972C-11D0-9567-00A0C9273C2A&quot;
WIDTH=100% HEIGHT=99%
CODEBASE=&quot;/viewer/activeXViewer/activexviewer.cab##Version=8,5,0,217&quot;>
<PARAM NAME=&quot;EnableRefreshButton&quot; VALUE=0>
<PARAM NAME=&quot;EnableGroupTree&quot; VALUE=0>
<PARAM NAME=&quot;DisplayGroupTree&quot; VALUE=0>
<PARAM NAME=&quot;EnablePrintButton&quot; VALUE=1>
<PARAM NAME=&quot;EnableExportButton&quot; VALUE=1>
<PARAM NAME=&quot;EnableDrillDown&quot; VALUE=1>
<PARAM NAME=&quot;EnableSearchControl&quot; VALUE=1>
<PARAM NAME=&quot;EnableAnimationControl&quot; VALUE=1>
<PARAM NAME=&quot;EnableZoomControl&quot; VALUE=1>
</OBJECT>

<!---disabling the refresh will avoid sending the user promts for URL parameters--->


<SCRIPT LANGUAGE=&quot;VBScript&quot;>
<!--
Sub Window_Onload
On Error Resume Next
Dim webBroker
Set webBroker = CreateObject(&quot;WebReportBroker.WebReportBroker&quot;)
if ScriptEngineMajorVersion < 2 then
window.alert &quot;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.&quot;
CRViewer.ReportName = &quot;rptserver.asp&quot;
else
Dim webSource
Set webSource = CreateObject(&quot;WebReportSource.WebReportSource&quot;)
webSource.ReportSource = webBroker
webSource.URL = &quot;Directy/reports/Report.rpt&quot;
webSource.AddParameter &quot;USER0&quot;, &quot;UserName&quot;
webSource.AddParameter &quot;PASSWORD0&quot;, &quot;MyPassword&quot;
webSource.PromptOnRefresh = True
CRViewer.ReportSource = webSource
end if
CRViewer.ViewReport
End Sub
-->
</SCRIPT>

 
It runs at the moment the crystal webserver wasn't running *shame on me*
 
Get an eval of Recrystalize and let that generate some code. The eval has limitations, but if all you want is some working code it will get you going and you can modify it without bothering with Recrystallize.
 
i have a small Q.
r the AddParameter used below are the parameters for the report ot they are something related to login etc


webSource.AddParameter &quot;USER0&quot;, &quot;UserName&quot;
webSource.AddParameter &quot;PASSWORD0&quot;, &quot;MyPassword&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top