Solved

Passing SQL Statement to a Crystal Report

Posted on 2007-11-20
5
246 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
5 Comments
 
LVL 69

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

746 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now