Solved

Passing SQL Statement to a Crystal Report

Posted on 2007-11-20
5
256 Views
Last Modified: 2013-11-26
I  have an app developed in vs2005 ASP.NET 2.0 and I am using the integrated Crystal Reports for my reporting. I need to be able to pass a SQL statement to the report, is this possible? I am currently passing parameters to the report and I am able to generate the report. however I need to build the SQL statement withing VB.net and the pass it to the report and have the report generate the results based on that SQL Query.

thanks
0
Comment
Question by:larrystewart
[X]
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
5 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 250 total points
ID: 20319173
0
 
LVL 3

Expert Comment

by:JeffvClayton
ID: 20319298
 Dim cr As Object

     cr = New MyCrystalReport
     cr.Database.Dispose()
     cr.DataSourceConnections.Clear()

            Dim dA As New OleDb.OleDbDataAdapter(sql, Con)
            dA.Fill(dT)

            cr.SetDataSource(dT)
            CrystalReportViewer1.ReportSource = cr

Note: The fields in your report template need to be the same name and data type as the sql you are sending although if the sql results in fileds with names that dony match the report you can always change the name of the DataSet columns in code so they match
0
 
LVL 1

Expert Comment

by:Computer101
ID: 20591157
Forced accept.

Computer101
EE Admin
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.

734 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