There are several ways to add parameters in a section report. The following sections provide a step by step overview of adding parameters in a report.
When you add SQL parameters to a report, ActiveReports displays an Enter Report Parameters dialog where the user can enter the values to fetch from the database.
SELECT * FROM Products
INNER JOIN (Orders INNER JOIN [Order Details] ON Orders.OrderID= [Order Details].OrderID) ON Products.ProductID = [Order Details].ProductID WHERE Products.SupplierID = <%SupplierID|Enter Supplier ID|7%>
AND OrderDate >= #<%OrderDate|Order date from|11/1/1994|D%>#
AND Discontinued = <%Discontinued|Is this checked?|true|B%>
The SQL query above causes ActiveReports to display the following dialog to the user. The user can accept these or input other values to select report data.
You can add, edit, and delete parameters at run time. The following code demonstrates how to add a parameter and display its value in a Textbox control.
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste at beginning of code view. |
Copy Code
|
---|---|
Imports GrapeCity.ActiveReports.SectionReportModel |
Visual Basic.NET code. Paste INSIDE the ReportStart event. |
Copy Code
|
---|---|
Dim myParam1 As New Parameter() |
To write the code in C#
C# code. Paste at beginning of code view. |
Copy Code
|
---|---|
using GrapeCity.ActiveReports.SectionReportModel; |
C# code. Paste INSIDE the ReportStart event. |
Copy Code
|
---|---|
Parameter myParam1 = new Parameter(); |
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the FetchData event. |
Copy Code
|
---|---|
'Set textbox text equal to the value of the parameter. Me.txtParam1.Text = Me.Parameters("myParam1").Value |
To write the code in C#
C# code. Paste INSIDE the FetchData event. |
Copy Code
|
---|---|
//Set textbox text equal to the value of the parameter. this.txtParam1.Text = this.Parameters["myParam1"].Value; |
The parameter prompt dialog for a parameterized report depending on how you view the report.
To get a Parameter Dialog box
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the Form_Load event. |
Copy Code
|
---|---|
Dim rpt As New SectionReport1 Viewer1.Document = rpt.Document rpt.Run() |
To write the code in C#
C# code. Paste INSIDE the Form_Load event. |
Copy Code
|
---|---|
SectionReport1 rpt = new SectionReport1(); viewer1.Document = rpt.Document; rpt.Run(); |
To get a Parameter Panel in the Viewer sidebar
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the Form_Load event. |
Copy Code
|
---|---|
Dim rpt As New SectionReport1 Me.Viewer1.LoadDocument(rpt) |
To write the code in C#
C# code. Paste INSIDE the Form_Load event. |
Copy Code
|
---|---|
SectionReport1 rpt = new SectionReport1(); viewer1.LoadDocument(rpt); |