Generate a crystal report from a sql stored procedure.....

Posted on 2005-03-10
Medium Priority
Last Modified: 2008-02-01

I want to write a aspx page where it will display the crystal report. I will be passing some parameters to the sql stored procedure and depending on the result, i have to display the crystal report, how can i do that. Is that possible...

Question by:angireddy
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 33

Expert Comment

ID: 13511188
Yes, it's possible..

First, get the results of the stored procedure into a typed dataset
Second, Create a Crystal Report based on the Typed DataSet
Last, Add a Crystal Report Viewer to your aspx page, and set the ReportSource to the Crystal Report
LVL 16

Expert Comment

ID: 13513359
This will load the report (OrdersReport.rpt) with a field from a Stored Procedure in which I am passing a "@OrderID" input parameter in:

Private Sub CrystalReportViewer2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles CrystalReportViewer2.Load

      Dim spParam As String = "4965"               <<<< I'm hard coding here for testing
      Dim paramFields As CrystalDecisions.Shared.ParameterFields
      Dim paramField As CrystalDecisions.Shared.ParameterField
      Dim spValue As CrystalDecisions.Shared.ParameterDiscreteValue
      paramFields = New CrystalDecisions.Shared.ParameterFields
      paramField = New CrystalDecisions.Shared.ParameterField
      paramField.ParameterFieldName = "@OrderID"     <<<<<<< from stored procedure
      spValue = New CrystalDecisions.Shared.ParameterDiscreteValue
      spValue.Value = spParam
      CrystalReportViewer2.ParameterFieldInfo = paramFields
      Me.CrystalReportViewer2.ReportSource = New OrdersReport
   End Sub
LVL 16

Accepted Solution

MikeMCSD earned 2000 total points
ID: 13513370
These are basically the steps I used:

Add New item: Crystal Report . . pick Expert, Blank, or Existing.

Choose Data Source: use
OLD DB (ADO) for SQL Server, Oracle, MS Jet (Access, Exel)
Project Data for ADO.NET datasets from your application
ODBC DB (RDO) for all other ODBC-compliant drivers
Database Files for file-type database formats (.mdb) used in previous versions of CR
More Data Sources for XML files, Access/Excel through DAO, Crystal Field Definitions (TTX)

When adding more than one table, you will need to link them.
Add fields through Fields tab.

Add a CrystalReportViewer to the form.

Drag a ReportDocument from the Components section on the form.
Choose the report to be opened (will be a "typed" report).  

Now put code in Page_Load or here:

Private Sub CrystalReportViewer2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles CrystalReportViewer2.Load

      Me.CrystalReportViewer2.ReportSource = New OrdersReport

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question