Reporting on DataSet in Crystal Reports

LerkHern

Member
Joined
Jul 7, 2005
Messages
7
Location
Chicago
Programming Experience
3-5
I'm trying to report off of a DataSet I have created in code. There is no DataSet in the designer and I do not want to put a dataset in the designer. How do I reference my DataSet created in code in Crystal Reports and how do I lay out the fields on the report so they will be bound to my dataset at runtime? All of the articles I've come across talk about adding a DataSet to the designer, but I'd rather keep it in code. Is this possible? (I believe I'm using Crystal Reports v10)
 
Nevermind, I figured it out. I generated an xml schema from the dataset and then refrenced that in my Crystal Report. This gave me all of the fields to lay out on the report. I then bound the dataset to the report.
Here's the code to generate an XML Schema from a DataSet:

DS.WriteXmlSchema("C:\filename.xsd")

Then on the report you go to
Add\Remove Database and in that screen select More Data Sources -> ADO.NET (XML) and click on Make New Connection. You then browse to your xsd file on the next screen. Wham! You have all of the fields in your dataset available to lay out on the report. Now you have to bind the report to the dataset which is very easy.
Dim rpt As New YourReport 'The report you created.

rpt.SetDataSource(YourDataSet)

When the report is opened in the report viewer or printed the data will automatically be bound to the fields!
 
Hello Lerk!

I have another problem, I have always in dataset diferent fileds and then how do i lay out the fields on the report if they are always differents?

Thanks
 
Back
Top