Click here to Skip to main content
16,017,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
previously my xml was like this

XML
<?xml version="1.0" encoding="UTF-8"?>
<root>
  <supplier>
    <s_code>1</s_code>
    <net_weight>100</net_weight>
    <rate>100.00</rate>
  </supplier>

  <supplier>
    <s_code>2</s_code>
    <net_weight>500</net_weight>
    <rate>150.00</rate>
  </supplier>
</root>


so i created a dataset and added columns similar to this and used this code to load data into dataset and use dataset to create crystal report.

C#
DataSet reportData = new DataSet();
reportData.ReadXml("http://192.168.1.10/test/data.xml");

DataSet dset = new DataSet1();
dset.Tables[0].Merge(reportData.Tables[0]);

ReportDocument report = new CrystalReport1();
report.SetDataSource(dset.Tables[0]);
reportViewer.ViewerCore.ReportSource = report;


so now i need to add more information to report and xml looks like this

XML
<?xml version="1.0" encoding="UTF-8"?>
<root>
  <supplier>
    <s_code>1</s_code>
    <net_weight>100</net_weight>
    <rate>100.00</rate>

    <items>
      <item_code>SKU001</items_code>
      <price>100</price>
    </items>
    <items>
      <item_code>SKU002</items_code>
      <price>200</price>
    </items>

  </supplier>

  <supplier>
    <s_code>2</s_code>
    <net_weight>500</net_weight>
    <rate>150.00</rate>

    <items>
      <item_code>SKU001</items_code>
      <price>100</price>
    </items>

  </supplier>

</root>


so any idea how to insert items into a dataset and use it in report?

Regards
Posted

Use this link.......This may help you....

http://www.dotnetperls.com/dataset[^]
 
Share this answer
 
Comments
gihanlasita 30-Jan-12 6:18am    
thanks it seems to be other way around.
Try like this..


System.Data.DataSet ds = new System.Data.DataSet();
                ds.ReadXml("xml filename");


Thanks
--RA
 
Share this answer
 
Comments
gihanlasita 30-Jan-12 6:19am    
same like i use though. problem is access items in crystal report

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900