Skip to Content
0

ASP.net issue report by using xsd as datasource throwing datasetconversion exception

Feb 17, 2017 at 10:24 AM

74

avatar image
Former Member

I'd struck for this problem by almost 2 full days ... hoping any guys can give little help to me ....

I need to issue several reports by using asp.net and crystal report :

  • SAP Crystal Repoort 2016 Support Pack 3 - Version 14.2.3.2132
  • Visual Studio 2015 - Version 14.0.24720.00 Update 1

The report data are queried by the asp code and using custom class which having the same structures as those defined by the xsd files.

Below code is used to generate the custom dataset from database

        Public Function GetDsClaimMonthlyReport(ByVal dFm As DateTime) As DsRptMonthlyClaimReport
            Dim ds As New DsRptMonthlyClaimReport
            Dim sql As String
            sql = "SELECT TypeCode, Seq, Channel, TypeDesc, ReportDate, Submission, Paid, Declined, Closed, Withdrawn, Outstanding, TotalPaym FROM vwMonthlyClaimReport " + _
            " WHERE ReportDate=@SubmissionDateFm "
            'parameters
            Dim paramList(1) As SqlParameter
            paramList(0) = New SqlParameter("@SubmissionDateFm", DbType.DateTime)
            paramList(0).Value = dFm
            SQLHelper.FillDataset(ConnString, CommandType.Text, sql, ds, New String() {ds.Tables(0).TableName}, paramList)
            Return ds
        End Function	

Then specifying the dataset to report document:

            Dim rpt As New RptMonthlyClaims
            Dim da As New DLReport
            Dim ds As DataSet
            Dim dsm As DataSet
            Dim dsClaimChange As DataSet
            Dim dsTAT As DataSet
            Dim rptD As New ReportDocument
            Dim fileName As String
            Dim now As DateTime
            now = DateTime.Now.Date
            Dim dFm As DateTime
            Dim dTo As DateTime
            'first day of last month
            dFm = now.AddDays(now.Day * -1 + 1).AddMonths(-1)
            dTo = now.AddDays(now.Day * -1)
            gIdentityContext = CType(gASPNET, System.Security.Principal.WindowsIdentity).Impersonate
            rpt.SetParameterValue("@dateFm", dFm)
            rpt.SetParameterValue("@dateTo", dTo)
            gIdentityContext.Undo()
            Dim subRpt As SubreportObject
            ds = da.GetDsClaimMonthlyReport(dFm)
            'WL        
            subRpt = rpt.secWL.ReportObjects("Subreport1")
            rptD = subRpt.OpenSubreport("RptMonthlyClaimsSubWL.rpt")
            rptD.SetDataSource(ds)
			
			....

The xsd schema using for the report:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="DsRptMonthlyClaimReport" targetNamespace="http://tempuri.org/DsRptMonthlyClaimReport.xsd"
	elementFormDefault="qualified" attributeFormDefault="qualified" xmlns="http://tempuri.org/DsRptMonthlyClaimReport.xsd"
	xmlns:mstns="http://tempuri.org/DsRptMonthlyClaimReport.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema"
	xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
	<xs:element name="DsRptMonthlyClaimReport" msdata:IsDataSet="true">
		<xs:complexType>
			<xs:choice maxOccurs="unbounded">
				<xs:element name="vwMonthlyClaimReport">
					<xs:complexType>
						<xs:sequence>
							<xs:element name="TypeCode" type="xs:string" />
							<xs:element name="Seq" type="xs:int" minOccurs="0" />
							<xs:element name="Channel" type="xs:string" />
							<xs:element name="TypeDesc" type="xs:string" minOccurs="0" />
							<xs:element name="ReportDate" type="xs:dateTime" />
							<xs:element name="Submission" type="xs:decimal" minOccurs="0" />
							<xs:element name="Paid" type="xs:decimal" minOccurs="0" />
							<xs:element name="Declined" type="xs:decimal" minOccurs="0" />
							<xs:element name="Closed" type="xs:decimal" minOccurs="0" />
							<xs:element name="Withdrawn" type="xs:decimal" minOccurs="0" />
							<xs:element name="Outstanding" type="xs:decimal" minOccurs="0" />
							<xs:element name="TotalPaym" type="xs:decimal" minOccurs="0" />
						</xs:sequence>
					</xs:complexType>
				</xs:element>
			</xs:choice>
		</xs:complexType>
	</xs:element>
</xs:schema>

The most weird thing is using the same xsd and logic to generate report with no subreport is pretty fine, but if i set the datasource within subreport ... the datasetconversion exception will be threw ....

I had tried for many findings from google ... and still can't figure out the problem .... I am having no idea for the issue ....

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Don Williams
Mar 21, 2017 at 09:19 PM
0

There is no runtime with Crystal Reports, go here to get the .NET SDK package, first link to integrate into VS, all other are redist packages, do not install them on your DEV PC.

https://wiki.scn.sap.com/wiki/display/BOBJ/Crystal+Reports%2C+Developer+for+Visual+Studio+Downloads

Check permissions where the XML is located.

Try Fiddler to see if has access to it.

Don

Share
10 |10000 characters needed characters left characters exceeded