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

One asp page to view different reports

Status
Not open for further replies.

welshone

Programmer
Jul 30, 2001
414
0
0
GB
Hello,
at present when I want to create a new report for the web I also create a new asp page which points to the relevent report,( with the asp page are the parameters too).

how can I use just one asp page to open many different reports ?
 
Hi Welshone,
I am using the same technique to run crystal reports using ASP but when i try to run the report, i am getting, "server has not been found yet" right before i read the records. do you know what this means? Any sample code would be greatly appreciated.

thanks
 
Alright ?

this is a sample asp page I am using to create crystal reports on the web.

<%@ LANGUAGE=&quot;VBSCRIPT&quot; %>
<title>A001</title>

<%

reportname = &quot;A001.01 Admissions Extract.rpt&quot;

%>

<SCRIPT Language=Javascript>
function HideHourGlass(){
szNavVersion = navigator.appVersion // Hide the 'retreiving records' display
if (szNavVersion.indexOf (&quot;4.&quot;) >= 0 || szNavVersion.indexOf (&quot;5.&quot;) >= 0) {
if (navigator.appName == &quot;Netscape&quot;){
document.layers[&quot;StatusText&quot;].visibility=&quot;hide&quot;
}else{
if (document.all(&quot;StatusIE&quot;)){
document.all(&quot;StatusIE&quot;).style.visibility = &quot;hidden&quot;;
}
}
}
}
</SCRIPT>
<BODY onLoad=&quot;HideHourGlass()&quot;>
<DIV ID=&quot;StatusIE&quot;><LAYER ID=&quot;StatusText&quot;><center>Generating Report, Please Wait... </center></LAYER></DIV>


<%

If Not IsObject (session(&quot;oApp&quot;)) Then
Set session(&quot;oApp&quot;) = Server.CreateObject(&quot;Crystal.CRPE.Application&quot;)
End If


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


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(path & ReportName, 1)


Set oRptOptions = Session(&quot;oRpt&quot;).Options
oRptOptions.MorePrintEngineErrorMessages = 0
session(&quot;oRpt&quot;).DiscardSavedData
%>


<%

userid = &quot;ed&quot;
password = &quot;ed&quot;


'session(&quot;oRpt&quot;).MorePrintEngineErrorMessages = False
'session(&quot;oRpt&quot;).EnableParameterPrompting = False

' Set the location
set crtable = session(&quot;oRpt&quot;).Database.Tables.Item(1)
crtable.SetLogonInfo &quot;DATABASE_NAME&quot;, &quot;ODBC_NAME&quot;, cstr(userid), cstr(password)

%>

<%

On Error Resume Next
session(&quot;oRpt&quot;).ReadRecords
If Err.Number <> 0 Then
Response.Write &quot;An Error has occured on the server in attempting to access the data source&quot;
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

%>


<HTML>
<HEAD>
<TITLE>Seagate ActiveX Viewer</TITLE>
</HEAD>



<input type=&quot;button&quot; value=&quot; Close Report &quot; OnClick=&quot;document.location='./Default.htm';return false;&quot; id=button1 name=button1>

<BODY BGCOLOR=C6C6C6 LANGUAGE=VBScript ONLOAD=&quot;Page_Initialize&quot;>

<OBJECT ID=&quot;CRViewer&quot;
CLASSID=&quot;CLSID:C4847596-972C-11D0-9567-00A0C9273C2A&quot;
WIDTH=100% HEIGHT=95%
CODEBASE=&quot;/viewer/activeXViewer/activexviewer.cab#Version=2,2,4,28&quot;>
<PARAM NAME=&quot;EnableRefreshButton&quot; VALUE=1>
<PARAM NAME=&quot;EnableGroupTree&quot; VALUE=1>
<PARAM NAME=&quot;DisplayGroupTree&quot; VALUE=1>
<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>

<SCRIPT LANGUAGE=&quot;VBScript&quot;>
<!--
Sub Page_Initialize
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;rptserver.asp&quot;
webSource.PromptOnRefresh = True
CRViewer.ReportSource = webSource
end if
CRViewer.ViewReport
End Sub
-->
</SCRIPT>

</BODY>
</HTML>

hope this is of some help. come back to me if you have any queries.
 
Hi Welshone,
thanks for the code above, it really helped me get started. But when i put this code into my asp page, everything worked expect the viewer didn't show any report. It created an ActiveX viewer but the report wasn't there. So in other words, i am seeing a blank report. Any ideas why this is happening? For testing, i copied the path name and the report name into an IE browser and it worked fine. so i am not sure what the problem might be.

please let me know if you have any comments/suggestions

thanks,
 
The problem you describe (the ActiveX viewer displaying with no report) happened to me early on when I was first trying to get Crystal viewer to display my reports from ASP. It turned out to be a problem with Front Page server extensions generated by Visual InterDev that were in my global.asa file. I commented them out, and that solved the problem.

So if you see a bunch of lines in your global.asa file that look like the following, try commenting them out:

<!--==Visual InterDev Generated - startspan==-->
<METADATA TYPE=&quot;TypeLib&quot; NAME=&quot;Crystal Data Object&quot; UUID=&quot;{7C5A4C06-A559-11D0-881A-00AA00BA30B7}&quot; VERSION=&quot;1.0&quot;>
<METADATA TYPE=&quot;TypeLib&quot; NAME=&quot;Crystal Report 8 ActiveX Designer Run Time Library&quot; UUID=&quot;{B4741C00-45A6-11D1-ABEC-00A0C9274B91}&quot; VERSION=&quot;8.0&quot;>
 
I do not have tohose lines within my global.asa ??
 
Welshone, in answer to your original question, here's how you could do it:

1 - Assuming the parameters are the same for all reports, display a report name pick list on your page, so the user can select which report he/she wants to run. If the parameters are not the same, then change them depending on which report the user selects.
2 - pass the reportname to your ASP and voilà!

Hope that helps!
 
cheers mmaz,
I dont suppose you have any examples .?
 
Yes, as a matter of fact, I do. :)

Do you want sample code for the dynamic parameters, or for the creation of reports?
 
Sample code of dynamic parameters would be good.

cheers.
 
Hello,
To solve this problem, I had to unregister the crviewer.dll from my system32 folder, then run a crystal report from the web. this then downloads the corrrect Viewer.
 
Have any of you ever had to deal with the new licensing scheme Crystal implemented in ver 8.5? They allow 5 concurrent users of the crystal object that displays the report. Their sample code releases a user's license after a session timeout or the user goes to a different page. Has anyone experimented with moving that license release up to a point directly after the report is displayed? They give a &quot;cleanup.asp&quot; page that does the license release.
 
Hi Welshone,

I have Sample code for dynamic parameters. Create one include file and put all the report details like the following in a two dimentional array. Then create one generic ASP. From then calling ASP, just pass the report code and values for the parameters. You can use the same for sub reports also.

'ReportArr(0,1) = RptName without rpt extension
'ReportArr(0,2) = DBName
'ReportArr(0,3) = procedure name - used for non crystal reports only
'ReportArr(0,4) = In case of Sub reports give the report id of sub report. If more then

' Report Id : 1 -
ReportArr(1,1) = &quot;ReportsOrderReport&quot;
ReportArr(1,2) = &quot;SOM&quot;
ReportArr(1,3) = &quot;WEB_SOM_sp_Order_Report&quot;
ReportArr(1,4) = 0

do you want full source code?

I have one doubt. I referred your code for creating crystal report on the web. You have used Active X control crviewer.dll. Will it work in Netscape? Do I need to do anything to view the same in Netscape??
 
Hello, cheers for this, how ever full source code would be good.
I don't use netscape, so don't know if it will work.
 
hello, YES U CAN view a report in netscape but with de javaviewer jvm, crystal reports have it. you just need install crystal in your server, on your script you need to adjust to show the report within the javaviewr. it can't with active x because that's just for i.e., u know, microsoft suks
 
hello,
well,I displayed my report when i calling it as a url
say,
href=&quot;mdr.rpt?init=java&user0=hh&password=hh&prompt0=Test&quot;

This works fine. i found a problem when i explicitly set database connection.No error is output when Database.Table.Setlogoninfo is set.(err.number returned is 0) But Session(&quot;oRpt&quot;).ReadRecords is neither returning error or passing to the next statement. Brower is still running. When i commented this statement, an empty report viewer is displayed with no report on it.

To debug, i added some Response.write code in rptserver.asp
These statements are not executed. I am using Javaviewer.

Any one has idea? i don't know where i am mistaking.
 
I am currently calling a Crystal Report through an ActiveZ viewer. It calls the Cleanup.asp file to kill the session for licensing reasons. But when I kill the session, I lose the session in my app, and lose all my session variables. Is there a way to release the session for the licensing purposes of Crystal, but keep my session for my app?

Thanks.
 
i am launching the report(segate) from the asp file.during the that time some extra window has been(blank screen with tabcontrol as preview and tree control etc) loaded. after that all the resuls has come.i dont know what is name for that one.(this is my first report in my life ).and in the remaining pages some datas are hided.pls let me know the details.....
 
i am launching the report(segate) from the asp file.during the that time some extra window has been(blank screen with tabcontrol as preview and tree control etc) loaded. after that all the resuls has come.i dont know what is name for that one.(this is my first report in my life ).and in the remaining pages some datas are hided.pls let me know the details.....
 
DevElem,

int the Cleanup.asp file, remove these lines:
Code:
for each item in session.contents
	response.write item
next
session.contents.removeall
session.abandon
What those lines do is kill all of your session variables. What you need to do is put in these lines:
Code:
session.contents.remove(&quot;oEMF&quot;)
Session.Contents.Remove(&quot;oPageEngine&quot;)
Session.Contents.Remove(&quot;oRpt&quot;)
Session.Contents.Remove(&quot;oApp&quot;)
What this does is destroy the Crystal Report objects, leaving the rest of your session variables intact while reclaiming your licenses.

Also note in AlwaysRequiredSteps.asp and MoreRequiredSteps.asp there is a line:
Code:
Session.Abandon
Remove this. It will kill every session variable if you get a error in these two pages.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top