Omar Kh

Omar Kh

  • 1.3k
  • 301
  • 20.1k

how to make a RDLC report using xml string ?

Sep 11 2020 4:51 AM
im working on webservice and i have to make a rdlc report from xml string
the xml is 
  1. "<Data><Result>success</Result><Rowset><Row>\n<Date>01-09-2020</Date>\n<TrNo></TrNo>\n<Debit></Debit>\n<Credit></Credit>\n<Remark>Pre balance</Remark>\n<Balance>0</Balance>\n</Row><Row><Date>07-09-2020</Date><TrNo>203</TrNo><Debit>2.5</Debit><Credit></Credit><Remark> rem in 202003-452 JOD/??????? ???? ????????</Remark><Balance>-2.5</Balance></Row><Row><Date>07-09-2020</Date><TrNo>203</TrNo><Debit>452</Debit><Credit></Credit><Remark>rem in 202003-452 JOD/??????? ???? ????????</Remark><Balance>-454.5</Balance></Row><Row><Date>08-09-2020</Date><TrNo>2015</TrNo><Debit>355</Debit><Credit></Credit><Remark>rem in 2020015-500 USD/??????? ???? ????????</Remark><Balance>-809.5</Balance></Row><Row><Date>08-09-2020</Date><TrNo>2015</TrNo><Debit>1.5</Debit><Credit></Credit><Remark> rem in 2020015-500 USD/??????? ???? ????????</Remark><Balance>-811</Balance></Row><Row><Date>08-09-2020</Date><TrNo>2016</TrNo><Debit>163.3</Debit><Credit></Credit><Remark>rem in 2020016-230 USD/??? ????? ???? ????</Remark><Balance>-974.3</Balance></Row><Row><Date>08-09-2020</Date><TrNo>2016</TrNo><Debit>1.5</Debit><Credit></Credit><Remark> rem in 2020016-230 USD/??? ????? ???? ????</Remark><Balance>-975.8</Balance></Row><Row><Date>09-09-2020</Date><TrNo>2027</TrNo><Debit></Debit><Credit>500</Credit><Remark> paid rem 500 JOD / ??? ??????? ????</Remark><Balance>-475.8</Balance></Row><Row><Date>09-09-2020</Date><TrNo>2027</TrNo><Debit></Debit><Credit>1</Credit><Remark> paid rem 500 JOD / ??? ??????? ????</Remark><Balance>-474.8</Balance></Row></Rowset></Data>" 
ii have  added a dataset called st_DS and ,make a datatable with 6 cloumns
 
also i'v add a report 
then i added a web form with report viewer control
as 
  1. <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>  
  2.       <rsweb:ReportViewer ID="ReportViewer1" runat="server"></rsweb:ReportViewer> 

 then there is a button wich must do all the work
this is the code behind
  1. string xml_resp = objCmd.Parameters["p_out"].Value.ToString();  
  2.             XmlTextReader reader = new XmlTextReader(new System.IO.StringReader(xml_resp));  
  3.             st_DS stt = new st_DS();  
  4.             stt.ReadXml(new XmlTextReader(new System.IO.StringReader(xml_resp)));  
  5.               
  6.               
  7.             ReportViewer1.ProcessingMode = ProcessingMode.Local;  
  8.             ReportViewer1.LocalReport.ReportPath = Server.MapPath("st.rdlc");  
  9.             ReportViewer1.LocalReport.DataSources.Clear();  
  10.             ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("st_DS", stt.Tables["1"]));  
  11. //also tried//  ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("st_DS", stt.Tables["0"])); 
  12.             ReportViewer1.LocalReport.Refresh(); 
 but i got this error
 
 i have google it but with no luck at all !
im so confused that there is a better,easier way to do it but i cant find it ! i need help , thank you

Answers (3)