Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Passing SQL Statement to a Crystal Report

Posted on 2007-11-20
5
Medium Priority
?
261 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 70

Accepted Solution

by:
Éric Moreau earned 1000 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

916 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