cancel
Showing results for 
Search instead for 
Did you mean: 

CrystalDecisions.ReportSource.ReportSourceFactory threw an exception

sergiotorresc
Explorer
0 Kudos

I am using:

Windows 10 Pro 64 bits Version 1511 (OS Build 10586.71) on an i7-4790 CPU

Visual Studio Professional 2015 Version 14.0.24720.00 Update 1

Crystal Reports for Visual Studio 13.0.16 (downloaded and installed today Feb/01/2016).

I installed the Crystal Reports runtime engine for .NET Framework 4 (64-bit)

I followed the instructions in the Tutorial "Connecting to ADO.NET DataSets" (I changed the data source to SQL Server 2014 Express).

I built the application and there was no error reported.

When I tried to debug I got the error message:

An error occurred creating the form.

See Exception.InnerException for details.

The error is: The type initializer for 'CrystalDecisions.ReportSource.ReportSourceFactory' threw an exception."

The application was being compiled to Any CPU I changed it to X86 (copying the settings from the Any CPU configuration). The error message appeared again.

The application was targeting .NET Framework 4.5.2 I changed it to 4. The error message appeared again.

I deleted the application and followed the tutorial set by step again.

The error message is still there.

What am I doing wrong? How can I solve this problem?

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi Sergio,

What instructions are you using? Do you have link to it?

Don

sergiotorresc
Explorer
0 Kudos

Hi Don,

Thank you for your fast answer.

I don’t have the code with me right now (I work in this project Mondays, Wednesdays and Fridays).

As soon as I get back to the office tomorrow I will send you all the content of the application. 

Thank you, again.

sergiotorresc
Explorer
0 Kudos

The application has the following CR references:

  CrystalDecisions.CrystalReports.Engine V. 13.0.2000.0

  CrystalDecisions.ReportSource              V. 13.0.2000.0

  CrystalDecisions.Shared                        V. 13.0.2000.0

  CrystalDecisions.Windows.Forms           V. 13.0.2000.0

  FlashControlV71                                     V. 1.0.3187.32366

The application has these files:

  App.Config

  Customer.rpt

  DataSetConfiguration.vb

  Form1.vb

  CustomerDataSetSchema.xsd (Under App_Code Folder)

App.config contains the following lines:

  <configuration>

    <startup useLegacyV2RuntimeActivationPolicy="true">

      <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>

    </startup>

    <configSections>

    </configSections>

      <connectionStrings>

          <add name="WindowsApplication1.My.MySettings.ConnectionString"

              connectionString="Provider=SQLNCLI11;Data Source=.\expresscatorce;Integrated Security=SSPI;Initial Catalog=RFQ"

            providerName="System.Data.OleDb" />

      </connectionStrings>

  </configuration>

Customer.rpt has the following properties:

  Build Action: Embedded Resource

  Copy to Output Directory: Do nos Copy

  Custom Tool: CrystalDecisions.VSDesigner.CodeGen.ReportCodeGenerator

  File Name: Customer.rpt

DataSetConfiguration.vb contains the following lines:

  Imports System.Data

  Imports System.Data.OleDb

  Public Class DataSetConfiguration

      Private Const CONNECTION_STRING As String = "Provider=SQLNCLI11;Data Source=.\expresscatorce;Integrated Security=SSPI;Initial Catalog=RFQ"

      Private Const QUERY_STRING As String = "SELECT Field1, Field2, Field3, Field4, Field5, Field6 FROM Table1 WHERE (Field1 = '10O2003001') AND (Field2 = '12345')"

      Private Const DATATABLE_NAME As String = "Customer"

      Public Shared ReadOnly Property CustomerDataSet() As DataSet

          Get

              Dim myDataSet As CustomerDataSetSchema = New CustomerDataSetSchema()

              Dim myOleDbConnection As OleDbConnection = New OleDbConnection(CONNECTION_STRING)

              Dim myOleDbDataAdapter As OleDbDataAdapter = New OleDbDataAdapter(QUERY_STRING, myOleDbConnection)

              myOleDbDataAdapter.Fill(myDataSet, DATATABLE_NAME)

              Return myDataSet

          End Get

      End Property

  End Class

The code for Form1.vb is

  Imports CrystalDecisions.CrystalReports.Engine

  Imports CrystalDecisions.Shared

  Public Class Form1

    Private customerReport As Customer

    Private Sub ConfigureCrystalReports()

        customerReport = New Customer()

        Dim myDataSet As DataSet

        myDataSet = DataSetConfiguration.CustomerDataSet

        customerReport.SetDataSource(myDataSet)

        CrystalReportViewer1.ReportSource = customerReport

    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        ConfigureCrystalReports()

    End Sub

  End Class

CustomerDataSetSchema.xsd is not generating code to insert, update and delete. It creates methods Fill and Return datatable

sergiotorresc
Explorer
0 Kudos

Customer.rpt has a customer.vb. Its content is:

'------------------------------------------------------------------------------

' <auto-generated>

'     This code was generated by a tool.

'     Runtime Version:4.0.30319.42000

'

'     Changes to this file may cause incorrect behavior and will be lost if

'     the code is regenerated.

' </auto-generated>

'------------------------------------------------------------------------------

Option Strict Off

Option Explicit On

Imports CrystalDecisions.CrystalReports.Engine

Imports CrystalDecisions.ReportSource

Imports CrystalDecisions.Shared

Imports System

Imports System.ComponentModel

Public Class Customer

    Inherits ReportClass

   

    Public Sub New()

        MyBase.New

    End Sub

   

    Public Overrides Property ResourceName() As String

        Get

            Return "Customer.rpt"

        End Get

        Set

            'Do nothing

        End Set

    End Property

   

    Public Overrides Property NewGenerator() As Boolean

        Get

            Return true

        End Get

        Set

            'Do nothing

        End Set

    End Property

   

    Public Overrides Property FullResourceName() As String

        Get

            Return "WindowsApplication1.Customer.rpt"

        End Get

        Set

            'Do nothing

        End Set

    End Property

   

    <Browsable(false),  _

     DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)>  _

    Public ReadOnly Property Section1() As CrystalDecisions.CrystalReports.Engine.Section

        Get

            Return Me.ReportDefinition.Sections(0)

        End Get

    End Property

   

    <Browsable(false),  _

     DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)>  _

    Public ReadOnly Property Section2() As CrystalDecisions.CrystalReports.Engine.Section

        Get

            Return Me.ReportDefinition.Sections(1)

        End Get

    End Property

   

    <Browsable(false),  _

     DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)>  _

    Public ReadOnly Property GroupHeaderSection1() As CrystalDecisions.CrystalReports.Engine.Section

        Get

            Return Me.ReportDefinition.Sections(2)

        End Get

    End Property

   

    <Browsable(false),  _

     DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)>  _

    Public ReadOnly Property GroupHeaderSection2() As CrystalDecisions.CrystalReports.Engine.Section

        Get

            Return Me.ReportDefinition.Sections(3)

        End Get

    End Property

   

    <Browsable(false),  _

     DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)>  _

    Public ReadOnly Property Section3() As CrystalDecisions.CrystalReports.Engine.Section

        Get

            Return Me.ReportDefinition.Sections(4)

        End Get

    End Property

   

    <Browsable(false),  _

     DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)>  _

    Public ReadOnly Property GroupFooterSection2() As CrystalDecisions.CrystalReports.Engine.Section

        Get

            Return Me.ReportDefinition.Sections(5)

        End Get

    End Property

   

    <Browsable(false),  _

     DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)>  _

    Public ReadOnly Property GroupFooterSection1() As CrystalDecisions.CrystalReports.Engine.Section

        Get

            Return Me.ReportDefinition.Sections(6)

        End Get

    End Property

   

    <Browsable(false),  _

     DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)>  _

    Public ReadOnly Property Section4() As CrystalDecisions.CrystalReports.Engine.Section

        Get

            Return Me.ReportDefinition.Sections(7)

        End Get

    End Property

   

    <Browsable(false),  _

     DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)>  _

    Public ReadOnly Property Section5() As CrystalDecisions.CrystalReports.Engine.Section

        Get

            Return Me.ReportDefinition.Sections(8)

        End Get

    End Property

End Class

<System.Drawing.ToolboxBitmapAttribute(GetType(CrystalDecisions.[Shared].ExportOptions), "report.bmp")>  _

Public Class CachedCustomer

    Inherits Component

    Implements ICachedReport

   

    Public Sub New()

        MyBase.New

    End Sub

   

    <Browsable(false),  _

     DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)>  _

    Public Overridable Property IsCacheable() As Boolean Implements CrystalDecisions.ReportSource.ICachedReport.IsCacheable

        Get

            Return true

        End Get

        Set

            '

        End Set

    End Property

   

    <Browsable(false),  _

     DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)>  _

    Public Overridable Property ShareDBLogonInfo() As Boolean Implements CrystalDecisions.ReportSource.ICachedReport.ShareDBLogonInfo

        Get

            Return false

        End Get

        Set

            '

        End Set

    End Property

   

    <Browsable(false),  _

     DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)>  _

    Public Overridable Property CacheTimeOut() As System.TimeSpan Implements CrystalDecisions.ReportSource.ICachedReport.CacheTimeOut

        Get

            Return CachedReportConstants.DEFAULT_TIMEOUT

        End Get

        Set

            '

        End Set

    End Property

   

    Public Overridable Function CreateReport() As CrystalDecisions.CrystalReports.Engine.ReportDocument Implements CrystalDecisions.ReportSource.ICachedReport.CreateReport

        Dim rpt As Customer = New Customer()

        rpt.Site = Me.Site

        Return rpt

    End Function

   

    Public Overridable Function GetCustomizedCacheKey(ByVal request As RequestContext) As String Implements CrystalDecisions.ReportSource.ICachedReport.GetCustomizedCacheKey

        Dim key As [String] = Nothing

        '// The following is the code used to generate the default

        '// cache key for caching report jobs in the ASP.NET Cache.

        '// Feel free to modify this code to suit your needs.

        '// Returning key == null causes the default cache key to

        '// be generated.

        '

        'key = RequestContext.BuildCompleteCacheKey(

        '    request,

        '    null,       // sReportFilename

        '    this.GetType(),

        '    this.ShareDBLogonInfo );

        Return key

    End Function

End Class

0 Kudos

Thank you...

Use this when setting the reports source to a dataset:

ISCRDataSet DS1 = (ISCRDataSet) CrystalDecisions.ReportAppServer.DataSetConversion.DataSetConverter.Convert(ds);

rptClientDoc.DatabaseController.SetDataSource(DS1, "TableName 1", "TableName 2");

Don

sergiotorresc
Explorer
0 Kudos

Thank you, Don, for your help.

I have two problems with your solution:

1) I don't understand your code (I suppose it is some kind of C language, which I don't know). It would be great if you provide me with the VB.NET equivalent.

2) I am guessing your solution uses the ReportClientDocument object model (that is nor part of the CR for VS). I tried to create the DS1 data set, but CrystalDecisions.ReportAppServer. has no DataSetConversion member.

Using the Object Browser I searched CR classes for "DataSetConversion" and found none.

Maybe you can help me to make sense of this?

0 Kudos

It's C#, easy to convet to Vb code, or search the WEB, there are sites that will do it for you:

Add these assemblies:

using CrystalDecisions.CrystalReports.Engine;

using CrystalDecisions.Shared;

using CrystalDecisions.ReportAppServer;

using CrystalDecisions.ReportAppServer.ClientDoc;

using CrystalDecisions.ReportAppServer.Controllers;

using CrystalDecisions.ReportAppServer.ReportDefModel;

using CrystalDecisions.ReportAppServer.CommonControls;

using CrystalDecisions.ReportAppServer.CommLayer;

using CrystalDecisions.ReportAppServer.CommonObjectModel;

using CrystalDecisions.ReportAppServer.ObjectFactory;

using CrystalDecisions.ReportAppServer.Prompting;

using CrystalDecisions.ReportAppServer.DataSetConversion;

using CrystalDecisions.ReportAppServer.DataDefModel;

using CrystalDecisions.ReportSource;

using CrystalDecisions.Windows.Forms;

Declare the report objects:

CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument rptClientDoc;

load and assign the ClientDocument to the RAS ReportClientDocument:

rpt.Load(rptName.ToString(), OpenReportMethod.OpenReportByTempCopy);

rptClientDoc = rpt.ReportClientDocument;

sergiotorresc
Explorer
0 Kudos

I added the references to the project and received a warning for each of the new references of the type:

Warning

A reference was created to embedded interop assembly

'CrystalDecisions.ReportAppServer.DataDefModel, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304'

because of an indirect reference to that assembly from assembly

'CrystalDecisions.Shared, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304'.

Consider changing the 'Embed Interop Types' property on either assembly.

I changed to True the 'Embed Interop Types' property for all the assemblies and it turned all the warnings to error.

I changed to False the 'Embed Interop Types' property for all the assemblies and warnings and errors disappeared.

I added the imports to the form1.vb code:

Imports CrystalDecisions.CrystalReports.Engine

Imports CrystalDecisions.ReportAppServer.ClientDoc

Imports CrystalDecisions.ReportAppServer.CommLayer

Imports CrystalDecisions.ReportAppServer.CommonControls

Imports CrystalDecisions.ReportAppServer.CommonObjectModel

Imports CrystalDecisions.ReportAppServer.Controllers

Imports CrystalDecisions.ReportAppServer.DataDefModel

Imports CrystalDecisions.ReportAppServer.DataSetConversion

Imports CrystalDecisions.ReportAppServer.ObjectFactory

Imports CrystalDecisions.ReportAppServer.Prompting

Imports CrystalDecisions.ReportAppServer.ReportDefModel

Imports CrystalDecisions.ReportSource

Imports CrystalDecisions.Shared

Imports CrystalDecisions.Windows.Forms

VS 2015 said they were not necessary and suggested to keep only two:

Imports CrystalDecisions.ReportAppServer.DataDefModel

Imports CrystalDecisions.Shared

The code I have (that I hope is your code translated to VB.NET) inside the form1.vb is:

Imports CrystalDecisions.ReportAppServer.DataDefModel

Imports CrystalDecisions.Shared

Public Class Form1

  Private customerReport As Customer

  Private sub ConfigureCrystalReports()

        Dim rpt = New CrystalDecisions.CrystalReports.Engine.ReportDocument()

         Dim rptClientDoc As CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument

        rpt.Load("Customer", OpenReportMethod.OpenReportByTempCopy)

         rptClientDoc = rpt.ReportClientDocument

        Dim ds1 As ISCRDataSet

         Dim myDataSet As DataSet

        myDataSet = DataSetConfiguration.CustomerDataSet

         ds1 = CrystalDecisions.ReportAppServer.DataSetConversion.DataSetConverter.Convert(myDataSet)

        rptClientDoc.DatabaseController.SetDataSource(ds1, "Customer", "Customer")

         CrystalReportViewer1.ReportSource = rptClientDoc

  end sub

  Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

      ConfigureCrystalReports()

  End Sub

End Class

I tried to debug (twice, one with all the imports and one with only the two suggested) and I am still receiving the original error message.

I tried changing line 3 to rpt.Load("Customer.rpt", OpenReportMethod.OpenReportByTempCopy). The error persisted.

I tried with the code

        Dim rpt = New CrystalDecisions.CrystalReports.Engine.ReportDocument()

        rpt = CustomerReport

        Dim rptClientDoc As CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument

        rpt.Load(rpt.Name.Tostring(), OpenReportMethod.OpenReportByTempCopy)

  ...

The error is still there.

What am I doing wrong?

0 Kudos

Hi Sergio,

Let back up to the beginning...

You may have just installed the x64 bit MSI which is a problem.

Uninstall anything you have installed for CR for VS and then install from this link:

http://downloads.businessobjects.com/akdlm/cr4vs2010/CRforVS_13_0_16.exe

Onto your DEV PC where VS is installed. At the end of the install it prompts if you want to install the 64 bit runtime, click OK.

Now try again, make sure you are running under a local Admin account and run the install by right clicking on the exe and selecting Run As Administrator.

Then start up VS by select Run as Administrator also.

Don

sergiotorresc
Explorer
0 Kudos

Hi Don,

A few days ago I installed CRforVS_13_0_16.exe and installed the 64 bits run time, i did it from an admin account.

Nevertheless, a few minutes ago I did as you instructed me:

1. Uninstalled all SAP CR applications (there were two).

2. Ran as admin CRforVS_13_0_16.exe and made sure the option Install 64 bits runtime was checked.

3. Restarted the developing PC.

4. Ran VS 2015 as admin and opened my application.

When I tried to debug my application:

First I got an error message related to the App.config file.

As per the tutorial instructions I had added to my app.config file "the following XML code within the top-level of the configuration tags.":

<startup useLegacyV2RuntimeActivationPolicy="true">

  <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>

</startup>

The App.config file had by default the tags <configSections> </configSections> and VS said:

     Only one <configSections> element allowed per config file and if present must be the first child of the root <configuration> element.

So first I moved the <configSections> element to the top-level of the configurations tags and tried to debug my application. Later I deleted the <configSections> element and tried to debug my application.

In both cases the application broke when trying to execute the following line of code:

rpt.Load("Customer.rpt", OpenReportMethod.OpenReportByTempCopy)

And the error message (comming from clientdoc.dll) is:

Unsupported Operation. A document processed by the JRC engine cannot be opened in the C++ stack.

The whole InnerException text is:

CrystalDecisions.Shared.CrystalReportsException was unhandled

  HResult=-2146232832

  Message=Load report failed.

  Source=CrystalDecisions.CrystalReports.Engine

  StackTrace:

       at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()

       at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob)

       at CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod)

       at WindowsApplication1.Form1.ConfigureCrystalReports() in C:\Users\Sergio\Documents\Visual Studio 2015\Projects\WindowsApplication1\WindowsApplication1\Form1.vb:line 9

       at WindowsApplication1.Form1.Form1_Load(Object sender, EventArgs e) in C:\Users\Sergio\Documents\Visual Studio 2015\Projects\WindowsApplication1\WindowsApplication1\Form1.vb:line 23

       at System.EventHandler.Invoke(Object sender, EventArgs e)

       at System.Windows.Forms.Form.OnLoad(EventArgs e)

       at System.Windows.Forms.Form.OnCreateControl()

       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)

       at System.Windows.Forms.Control.CreateControl()

       at System.Windows.Forms.Control.WmShowWindow(Message& m)

       at System.Windows.Forms.Control.WndProc(Message& m)

       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)

       at System.Windows.Forms.Form.WmShowWindow(Message& m)

       at System.Windows.Forms.Form.WndProc(Message& m)

       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)

       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)

       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

  InnerException:

       ErrorCode=-2147215343

       HResult=-2147215343

       Message=Unsupported Operation. A document processed by the JRC engine cannot be opened in the C++ stack.

       Source=clientdoc.dll

       StackTrace:

            at CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options)

            at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32 Options)

            at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()

       InnerException:

Waiting for your comments...

Sergio

0 Kudos

Obviously what ever document you are using to train on has issues....

Try a new Windows Form app, drop the CrystalViewer13 onto the form, this should add the Engine and Shared to the assembly list.

Then in form1 code add these 3 lines:

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

using CrystalDecisions.CrystalReports.Engine;

using CrystalDecisions.Shared;

namespace WindowsFormsApplication1

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

        private void crystalReportViewer1_Load(object sender, EventArgs e)

        {

            CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

            rpt.Load(@"c:\reports\formulas.rpt");

            crystalReportViewer1.ReportSource = rpt;

        }

    }

}

Use a report with saved data....

Does that work?

Don

sergiotorresc
Explorer
0 Kudos

Don,

I am not sure I understand what you're asking me to do.

I have a few CR reports that work just fine, only they are getting the data accessing directly the database.

The one that is not working is the one that tries to use a ADO.NET DataSet to populate the report as described in the "Connecting to ADO.NET DataSet" tutorial in help file crnet_dg_2010_en.hlp.

You ask me to  "Use a report with saved data..." would that reports with saved data use a ADO.NET DataSet? 

0 Kudos

This works for me. Create a new project, drop the CR viewer onto the form and copy this code into the form1.cs file:

To get the SQL from the Report create a new report off the tables and then Show SQL... and paste it into the code below. Or just do a SELECT * From Tables...

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

using CrystalDecisions.CrystalReports.Engine;

using CrystalDecisions.Shared;

using System.Data.OleDb;

namespace WindowsFormsApplication1

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

        private void crystalReportViewer1_Load(object sender, EventArgs e)

        {

            CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

            rpt.Load(@"c:\reports\formulas.rpt");

            // set to DS

            string connString = "Provider=SQLNCLI10;Server=10.161.14.188;Database=xtreme;User ID=sa;Password=MyPassword";

            System.Data.DataSet thisDataSet = new System.Data.DataSet();

            string sqlString = @"SELECT ""Customer"".""Customer Name"", ""Orders"".""Order Date"", ""Orders"".""Ship Date"", ""Customer"".""Country"", ""Orders"".""Order ID"" FROM   ""Customer"" ""Customer"" INNER JOIN ""Orders"" ""Orders"" ON ""Customer"".""Customer ID""=""Orders"".""Customer ID"" WHERE  ""Customer"".""Country""='Canada' ORDER BY ""Customer"".""Customer Name"", ""Orders"".""Order Date""";

            System.Data.OleDb.OleDbConnection oleConn = new System.Data.OleDb.OleDbConnection(connString);

            System.Data.OleDb.OleDbCommand cmd = oleConn.CreateCommand();

            cmd.CommandText = sqlString;

            System.Data.DataSet ds = new System.Data.DataSet();

            OleDbDataAdapter oleAdapter = new OleDbDataAdapter(sqlString, oleConn);

            //OleDbDataAdapter oleAdapter2 = new OleDbDataAdapter(sqlString2, oleConn);

            DataTable dt1 = new DataTable("Customer");

            DataTable dt2 = new DataTable("Orders");

            oleAdapter.Fill(dt1);

            oleAdapter.Fill(dt2);

            ds.Tables.Add(dt1);

            ds.Tables.Add(dt2);

            //ds.WriteXml("c:\\reports\\sc2.xml", XmlWriteMode.WriteSchema);

            // as long as the field names match exactly Cr has no problems setting report to a DS.

            try

            {

                rpt.SetDataSource(ds.Tables[0]);

                rpt.SetDataSource(ds.Tables[1]);

                rpt.SetDataSource(ds);

            }

            catch (Exception ex)

            {

                MessageBox.Show("ERROR: Schema Mismatch. Error reported by CR: " + ex.Message);

            }

            crystalReportViewer1.ReportSource = rpt;

        }

    }

}

And my app.config file looks like this:

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

  <startup useLegacyV2RuntimeActivationPolicy="true">

        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />

    </startup>

</configuration>

Don

sergiotorresc
Explorer
0 Kudos

Thank you, Don.

I am being urged to advance in the project, so I'll not use (for now) the ADO.NET DataSet. Eventually I'll try again.

0 Kudos

And my app.config file looks like this:

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

  <startup useLegacyV2RuntimeActivationPolicy="true">

        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />

    </startup>

</configuration>

Is a MUST for ADO.NET datasets....

Never going to work with out it.

Don

Answers (0)