Click here to Skip to main content
15,896,606 members

How Do I Load Data From Database To Xml File And Display The Xml File Data On Ms Reportviewer

Uwakpeter asked:

Open original thread
i am trying to load and display report from xml file, i was able to do this using crystal report, i am having some difficulties doing this with microsoft report. please anyone know how to do this?

here is my code using crystal report:

The XML File:

HTML
 <pre><xs:schema id="PersonalKYCRep" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
  <xs:element name="CorpKYCDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="CorpKYCReportFile">
          <xs:complexType>
            <xs:sequence>
             
              <xs:element name="ContactName" type="xs:string" minOccurs="0" />
              <xs:element name="ContactPhone" type="xs:string" minOccurs="0" />
              <xs:element name="ContactEmail" type="xs:string" minOccurs="0" />
              <xs:element name="CurrentAddress1" type="xs:string" minOccurs="0" />
              <xs:element name="CurrentAddress2" type="xs:string" minOccurs="0" />
              <xs:element name="CurrentCity" type="xs:string" minOccurs="0" />
              <xs:element name="CurrentState" type="xs:string" minOccurs="0" />
              
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:choice>
    </xs:complexType>
  </xs:element>
</xs:schema>


The C# Code:

C#
ReportDocument NRep = new ReportDocument();

public void filler(String table, int ind)
    {
        if (ind == 0)
            myDataSet.Clear();
        myAdapter.Fill(myDataSet, table);
    }

public DataSet corDetail(string RecordID, int source)
    {

using (SqlConnection myConn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
        {
            myConn.Open();
           
            SqlCommand cmd = new SqlCommand("AVS_usp_GetPhcnByIDReport", myConn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@RecordID", SqlDbType.VarChar).Value = RecordID;
            cmd.Parameters.Add("@source", SqlDbType.Int).Value = source;
            //SqlDataReader rdr = new SqlDataReader();

            myAdapter = new SqlDataAdapter() ;
            myDataSet = new DataSet();
            myAdapter.SelectCommand = cmd;
            if (source == 1)
            {
                filler("PersonalKYCRep", 0);
            }
            else
            {
                filler("SubReportFile", 0);
            }
            return myDataSet;
        }
    }
}


Please any assistance will be appreciated. Thanks in advance
Tags: C# 5.0

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



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