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

Help with Passing Parameters Please

Status
Not open for further replies.

linuxjr

Programmer
Jun 2, 2001
135
US
I apologize if there is already a similiar post but could not find it. I have been successful in figuring out how to pass parameters, login information and other things from this forum.

My problem I have now is I'm trying to port all my crystal reports to be accessible by the web as a web reporting package. I have 10 reports and ten pages/interfaces for these reports. I know there is a cleaner way then having to build 10 popup windows to pass parameters and other information to run a report.

I wanted to know if anyone has any information or know of some tutorials that could show me how to build one aspx page that I can pass report name, parameter collection, login collection, etc.. Basically when the user clicks run report it opens up another window displaying the report and refreshes when the user changes his/her selection criteria while hitting run report again.

Any information or hints will be greatly appreciated. Have a great day.
 
I just finished a project similiar your question.
Use dataset or datareader, besed on user input, you can change "where ..." in select SQL statement. like:
"select * from mydatable where xxx = ' " & user_input & "'"

 
I'm not exactely sure what kind of interface you are trying to use but I'm going to make some guesses and then some suggestions. If I am wrong just let me know what you are doing and then I will help. Ok, first I'm assuming that you are have a page and from that page you can click on a particular report to run, maybe from a dropdown or individual links. Now, if you are using a dropdown box is to use the selected index change event and put
Code:
Dim YourVariableToPass As String = "Report Name or whatever"
Response.Redirect("yourreportpage.aspx?ID=" & YourVariableToPass)

On yourreportpage.aspx you are going to have a Crystal Report Viewer. Put this code in the Page Load event

Code:
Dim variable As String
Dim rptCrystalReport2 As New CrystalReport2()
variable = Request.QueryString.Item("ID") 'This is where your variable from the last page comes through
SqlDataAdapter1.SelectCommand.Parameters(1).Value = variable
SqlDataAdapter1.Fill(YourDataSet)
rptCrystalReport2.SetDataSource(YourDataSet)
CrystalReportViewer1.ReportSource = rptCrystalReport2

This is passing one variable from the last page, you can of course pass as many as you need, I hope this gives you an idea of what you need. Let me know

Chris
 
ceyhorn and adonet,

Thank you for responding to my question. I will explain a little more of what I'm trying to accomplish for my web pages.
First off I'm using Crystal Reports version 10 for .NET.

I have 10 reports and 10 interfaces:

Report1.aspx is an interface for Report1.rpt
Report2.aspx is an interface for Report2.rpt
....
....

Each of these reports have different number of paramaters ranging from 3 to 20.

I did a sample aspx page that has 2 text boxes, a crystalreport viewer and a button that says run report. The parameters are date parameters.

So here is my code(C# and extracted from the samples provided by Business Objects) that I did to accomplish to be able to
display the report within the crystal viewer:

// CR Variables
Reports.Report1 crReportDocument;
ParameterFields crParameterFields;
ParameterField crParameterField;
ParameterValues crParameterValues;
ParameterDiscreteValue crParameterDiscreteValue;

//Create an instance of the strongly-typed report object
crReportDocument = new Reports.Report1();

//The viewer's reportsource must be set to a report before any
//parameter fields can be accessed.
CrystalReportViewer1.ReportSource = crReportDocument;

//Get the collection of parameters from the report
crParameterFields = CrystalReportViewer1.ParameterFieldInfo;
crParameterField = crParameterFields["BEGINDATE"];
//Get the current values from the parameter field. At this point
//there are zero values set.
crParameterValues = crParameterField.CurrentValues;

//Set the current values for the parameter field
crParameterDiscreteValue = new ParameterDiscreteValue();
crParameterDiscreteValue.Value = "2003-01-01";
crParameterValues.Add(crParameterDiscreteValue);
crParameterDiscreteValue = null;

crParameterField = crParameterFields["ENDDATE"];
crParameterValues = crParameterField.CurrentValues;
crParameterDiscreteValue = new ParameterDiscreteValue();
crParameterDiscreteValue.Value = "2003-12-31";
crParameterValues.Add(crParameterDiscreteValue);

I know the values are hard coded but this is to show you what is being passed once the user hits run report. Now the crystal viewer will
display the report. I don't like having the viewer on the bottom of the page and I need the form fields so
the user can change his/her parameter choices. I now just want to keep things simple and have another aspx page lets call it displayreport.aspx
that will be a popup child window that I can pass the information from Report1.aspx or Report2.aspx ... and display the report.

So basically pass the report document, the parameter information collected on the main aspx page (report1.aspx, report2.aspx ....) and other
information like sorting, grouping changes etc. and send it to displayreport.aspx so that it will display the report. I hope this makes a little more
sense and if it doesn't I can add some more information.

Any assistance or tips will be greatly appreciated.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top