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!

Adding a Parameter Field through ASP

Status
Not open for further replies.

LV

Programmer
Nov 1, 2000
1,184
0
0
US
Here is the problem:
I'm building a report from scratch dynamicaly through ASP.
I'm adding a parameter field to it so once the report is shown in the viewer, the user would be prompted for values and will be able to filter on some fields.
Everything is working fine until I set EnableParameterPrompting = true - I need it in order to bring up the parameter dialogue screen:
The browser just hangs - no error messages. If I set it to false, the report shows in the viewer as it supposed to but no prompting, of course. The parameter is there - I can see it if I export the report in Crystal format and open it in the Designer.
Any idea how to fix it?
Thanks in advance.
(Crystal 8.5, SQL Server 2000)
Here is my code:

<%
set session(&quot;oConn&quot;)=server.CreateObject(&quot;ADODB.Connection&quot;)
set session(&quot;oCmd&quot;)=server.CreateObject(&quot;ADODB.Command&quot;)

strConn = &quot;Provider=SQLOLEDB;Data Source=MYPC;Initial Catalog=test_db;User Id=sa;Password=;&quot;
session(&quot;oConn&quot;).Open(strConn)

session(&quot;oCmd&quot;).ActiveConnection = session(&quot;oConn&quot;)
session(&quot;oCmd&quot;).CommandText = &quot;Select cmp_city, cmp_state, cmp_zip From Company&quot;

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

If IsObject(session(&quot;oRpt&quot;)) then
Set session(&quot;oRpt&quot;) = nothing
End if
set session(&quot;oRpt&quot;) = session(&quot;oApp&quot;).NewReport

Set objDatabase = session(&quot;oRpt&quot;).Database
objDatabase.AddADOCommand session(&quot;oConn&quot;), session(&quot;oCmd&quot;)

'-------------------------------------------------
'-- Code to add fields to Detail Section goes here
'-------------------------------------------------

'this line hangs the browser
'session(&quot;oRpt&quot;).EnableParameterPrompting = true

'this works fine
session(&quot;oRpt&quot;).EnableParameterPrompting = false
set objParm = session(&quot;oRpt&quot;).ParameterFields.Add(&quot;parm1&quot;, 12)
session(&quot;oRpt&quot;).RecordSelectionFormula = &quot;{ado.cmp_city}={?parm1}&quot;

On Error Resume Next
session(&quot;oRpt&quot;).ReadRecords

if Err.Number <> 0 Then
Response.Write &quot;Read Records Didn't Go&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

%>

<!-- #include file=&quot;SmartViewerActiveX.asp&quot; -->
 
Just to make this a little shorter:
session(&quot;oRpt&quot;).EnableParameterPrompting = true
is hanging the browser, no matter where in the code I place it.
I repeated the same situation in VB (using the same CRAXDRT.dll) and it works just fine: the parameter is added
to the report on the fly and once the report opens, I'm getting prompted for the value.
Is it something Web-specific I'm not aware of?
Guys, I need your help!
 
LV, I am running into the same issue. Did you find a solution?

justin
 
No way to display the parameter dialog box using CRAXDRT in the Web environment.
The workaround I used:
1. Create a Report through the code, adding a parameter field object.
2. Then you need to kind of similate the parm dialog by popping up another page, in which you will loop through the newly created report parameter fields collection, retrieving them and displaying appropriate control(s) on this web page. Then you'll need to pass the values from this dialog page to the report parameter(s) and display the report itself.

Kind of a complicated procedure, but I didn't find anything better. Good luck!
 
LV, I built my parameter pages, the data is passing and the reports are being built. But, the reports with parameters open as Page 0 of 0+. Once you click the next page button all is fine, but confusing the users. I found this was listed as an error on Crystal's website for Crystal 7. I followed there solution, but nothing. Any suggestions?

justin
 
Well, I've never seen anything like that.
Honestly, I don't know. I would probably try to export the report from the Web Viewer to Crystal format and take a look at that exported report in the Designer...I don't know if it'll help.
OK, maybe this:somehow through the code force the report to show the very first page(although it already shows first page, when you first open it) and see what it will show in this case. Good luck.
 
I dont know if you guys have found the solution but the reason teh ASP page hangs is to do with the way the web works - the end web browser is not allowed to open a dialog in the same way as crystal does. Its a security thing to prevent 'rogue' web sites from running naughty bits of code on the target machines.

As has been rightly pointed out you will have to cycle through the parameters before launching the report and pass them over. You can write the complex piece LV talked about which would deal with any report but would take longer to build or just hardwire an intermediate page for each report that is exactly what you need.

PS LV if you have any code like that I would be interested in getting my paws on it if possible - as I am sure others would be too.

Exporting the report from the viewer wouldnt give you any clues as its not the report thats malfunctioning.

One thing I dont know is if the server itself pops up a dialog as if the report is run locally(which I supose it is)

Hope I helped

Iain
 
Iain,
I used this method in order to build a dynamic report (not axactly ad-hoc, but very close to it); in this the report is built from scrach.
If you have a pre-written report, then yes, you are absolutly right, it makes more sence to have a &quot;process&quot; page, adopted for each report, 'cause you have all info about the report, such as number of parameters, etc.
I sure can post the code. The only thing, it's a pretty big chunk, divided into several ASP pages, starting with gathering report info (that's pure HTML/DHTML/XML) and down to analyzing it and so on. Which part would you be interested in?
 

I am a glutton for looking at other peoples code examples. I would happily accept it all :) but if you have a page that filters through a parameter list and creates a masked input field for each then that sounds good for starters.
I am fairly new to these forums and dont see direct email or file transfer facilities - should I post my webmail addy? I already get plenty of spam into it so dont mind posting
 
I'll post it, no biggy :)
Just give me a day or so to spare some time to do it.
 
Sorry, I realize this thread is 3 years old, but I'm having the same problem in Crystal v10, and I was wondering if there's been any updates to work around this problem. I cannot really create a separate criteria page/function as I have way too many reports to work with.

Any advice/suggestions is greatly appreciated, thanks!
 
Sorry, I realize this thread is 3 years old, but I'm having the same problem in Crystal v10, and I was wondering if there's been any updates to work around this problem. I cannot really create a separate criteria page/function as I have way too many reports to work with.

Any advice/suggestions is greatly appreciated, thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top