Solved

Passing SQL Statement to a Crystal Report

Posted on 2007-11-20
5
249 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

863 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

19 Experts available now in Live!

Get 1:1 Help Now