Home All Groups Group Topic Archive Search About

How to create a dataset from XML for use in Crystal Reports

Author
9 Jan 2006 8:49 PM
Kirk
Hello,

I have an app that reads & writes to XML files.  I now would like to
create some reports using Crystal Reports, and the usual way I do this
is by creating a dataset in Visual Studio & inserting the fields
graphically.  However, I cannot find out how to do this within the VS
IDE.  I can create the dataset programatically like this:

    Dim filePath As String = "C:\Temp\XMLfile.xml"

    AuthorsDataSet.ReadXml(filePath)

    DataGridView1.DataSource = AuthorsDataSet
    DataGridView1.DataMember = "authors"

....but this created at runtime, and as such, I cannot use it at
design-time for my CR design work.

How can I create a dataset from an XML file at design time?

Thanx in advance.

Author
10 Jan 2006 2:29 AM
Elton W
Hi Kirk,

You don’t have to use Dataset to design your CR. You can use ttx file (field
definition file) as data schema to design the CR. And it’s very easy to use
even Notepat to create a ttx file.


HTH

Elton Wang


Show quote
"Kirk" wrote:

> Hello,
>
> I have an app that reads & writes to XML files.  I now would like to
> create some reports using Crystal Reports, and the usual way I do this
> is by creating a dataset in Visual Studio & inserting the fields
> graphically.  However, I cannot find out how to do this within the VS
> IDE.  I can create the dataset programatically like this:
>
>     Dim filePath As String = "C:\Temp\XMLfile.xml"
>
>     AuthorsDataSet.ReadXml(filePath)
>
>     DataGridView1.DataSource = AuthorsDataSet
>     DataGridView1.DataMember = "authors"
>
> ....but this created at runtime, and as such, I cannot use it at
> design-time for my CR design work.
>
> How can I create a dataset from an XML file at design time?
>
> Thanx in advance.
>
>
Author
10 Jan 2006 8:49 PM
Kirk
Elton,

Thanks for your reply.  After some struggling, I was able to create a
ttx file to use as I am designing my report (thank you!).  However, I
am having a problem populating the report with data from my dataset.  I
use the same code as above, but after I populate my dataset, I do this:

   Dim crReport As New TcReport01
   crReport.SetDataSource(AuthorsDataSet) 'Set the data source for the
report
   CrystalReportViewer1.ReportSource = crReport 'Set the report to view

And all the report shows (in the detail section) is the default value
in my TTX file.  For example, my TTX file looks like this:

  ; Field definition file for table: ADORecordset
  Description    String    20    Default

But the the detail on the report always shows just "Default".  Can
anyone see where I am going wrong?

Thanks.
Author
12 Jan 2006 3:28 AM
Elton W
Hi Kirk,

Two possible reasons:

1. The report might be in a Save Data with Report mode. It always shows data
in design time. You can open report in Seagate Report Designer. From Menu
File uncheck Save Data with Report, then save the report.

2. It’s better to use DataTable as report’s data source like following:

Report.Database.Tables[0].SetDataSource(datatable0);   
Report.Database.Tables[1].SetDataSource(datatable1);
…

HTH

Elton Wang

Show quote
"Kirk" wrote:

> Elton,
>
> Thanks for your reply.  After some struggling, I was able to create a
> ttx file to use as I am designing my report (thank you!).  However, I
> am having a problem populating the report with data from my dataset.  I
> use the same code as above, but after I populate my dataset, I do this:
>
>    Dim crReport As New TcReport01
>    crReport.SetDataSource(AuthorsDataSet) 'Set the data source for the
> report
>    CrystalReportViewer1.ReportSource = crReport 'Set the report to view
>
> And all the report shows (in the detail section) is the default value
> in my TTX file.  For example, my TTX file looks like this:
>
>   ; Field definition file for table: ADORecordset
>   Description    String    20    Default
>
> But the the detail on the report always shows just "Default".  Can
> anyone see where I am going wrong?
>
> Thanks.
>
>
Author
12 Jan 2006 8:04 PM
Kirk
Elton,

Thanks for your great response.  I followed your second option and was
able to get my report to work!

I changed the code to this:

crReport.Database.Tables(0).SetDataSource(AuthorsDataSet.Tables(0))

....and it worked correctly.

Thanks for following up with me and getting me past this hurdle.  I
greatly appreciate your help!
Kirk
Author
13 Jan 2006 7:00 PM
Elton W
I'm very glad that helped.

Show quote
"Kirk" wrote:

> Elton,
>
> Thanks for your great response.  I followed your second option and was
> able to get my report to work!
>
> I changed the code to this:
>
> crReport.Database.Tables(0).SetDataSource(AuthorsDataSet.Tables(0))
>
> ....and it worked correctly.
>
> Thanks for following up with me and getting me past this hurdle.  I
> greatly appreciate your help!
> Kirk
>
>

AddThis Social Bookmark Button