Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Passing SQL Statement to a Crystal Report

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
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.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

722 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