Since there doesn’t seem to be any way to load old VB6 (ActiveReports) reports in .Net, I need to recreate dozens of reports in .Net. I’d like to do this in the least painful way possible.
In VB6, the original authors simply did something like this for every report:
adoConn.ConnectionString = globalConnectionObject.ConnectionString
adoConn.Source = ReportFunctions.GetAllUsers()
GetAllUsers() returns an SQL string which selects a bunch of fields; those fields are then used in the report.
Now:
How can I do something similar in .Net (either using the built-in Crystal Reports, or the built-in “Microsoft Reporting Technology”)?
I can’t get “Database Expert” to recognize globalConnectionObject (an ADODB.Connection object); and if I fill a dataset and do
report.SetDataSource(dataSet)
It tells me “The report has no tables.”
How do I populate a Crystal Reports report!? (the connection string/data location is not known at compile time)
Creating Connection:
using above connection Populate dataset manually or Add a dataset to your solution to get data without writing connection codes. Say You have added Employee.XSD. Add a tableadapter in the XSD which will help you in pulling data from database, by auto generating queries and datatables. After doing all these things. Create a method somewhere in your project,
Now on Your Form add a reportviewer control.
Before that From Crystal Report , add the fields of table on the report as per your requirement.
Another Way To achieve
Crystal Reports can be used over various objects. If you have scenario to bind it dynamically, see my answer below Then u can do one thing that is , add a new dataset to solution. Create a datatable and add required columns with appropriate data type. DO not add query or table adapter. Now from your code add a class file and create properties exactly similar to the datatable columns. Now set the datatable as source to report and add its column on the report.
Create a class
Now create another function that will populate the datatable created inside the dtataset.