Rpt.SetDataSource ignores my dataset

I have an app that passes a dataset to the crystal report viewer.
If I use the following line the data gets passed to the viewer, however if a crosstab is used in the report the crosstab ignores the column group options. If a crosstab is not used everything is fine.
rpt.setdatasource(mydataset.tables(0))
If I use the following line the the viewer/report ignores my dataset entirely and loads the data from the source the report was written from.
rpt.setdatasource(mydataset)
So I guess my question is how to I get the crosstab to work when I specify the actual table in my dataset.
I'm using vb.net 2005 and Crystal 2008 version 12.2.0.290.
Thank You

See if you can reproduce the issue in the CR designer as per the following blog:
/people/ludek.uher/blog/2009/03/02/troubleshooting-issues-with-vs-net-datasets-and-crystal-reports
If you can, I may be able to test this, but I will need to obtain the report as well as the XML from you. Before testing, I will also need you to be on FP2.7:
https://smpdl.sap-ag.de/~sapidp/012002523100005755702010E/cr2008fp27.exe
Ludek
Follow us on Twitter http://twitter.com/SAPCRNetSup

Similar Messages

  • Flarecreate for zfs root dataset and ignore multiple dataset

    Hi All,
    I want to write a script to create flar images on multiple servers. In non zfs filesystem I am using -X option to refer a file to exclude mounts on different servers.
    but on ZFS -X option is not working. I want multiple mounts to be ignore on ZFS base system during flarecreate.
    I can use -D option to ignore the datasets on the server but it is not serving my purpose as i am maintaining a common file to ignore the mounts on all different servers.
    Please help me in this

    Renaming the root pool is not recommended.

  • CRVS2010 Beta - Crash on SetDataSource

    I have a simple report that I am trying to get to run in a C#/Visual Studio 2010 WPF project.  I am trying to populate the data from a dataset that I am populating from a list.  The following code populates the dataset:
            private MainDataSet GetDataSetFromList(List<MainBvaReportRecord> lst)
                MainDataSet ds = new MainDataSet();
                MainDataSet.BVA_TEST_DATA_VIEWDataTable dt = (MainDataSet.BVA_TEST_DATA_VIEWDataTable)ds.Tables[0];
                foreach (MainBvaReportRecord rcd in lst)
                    DataRow row = dt.NewRow();
                    row["HOSPITAL_NAME"] = rcd.HospitalName;
                    row["DEPARTMENT_NAME"] = rcd.DepartmentName;
                    row["DEPARTMENT_ADDRESS"] = rcd.DepartmentAddress;
                    row["DEPARTMENT_DIRECTOR"] = rcd.DepartmentDirector;
                    row["DEPARTMENT_PHONE_NUMBER"] = rcd.DepartmentPhoneNumber;
                    row["FIRST_NAME"] = rcd.FirstName;
                    row["MIDDLE_NAME"] = rcd.MiddleName;
                    row["LAST_NAME"] = rcd.LastName;
                    dt.Rows.Add(row);
                return ds;
    I try and use the dataset in the Window_Loaded event:
                try
                    List<MainBvaReportRecord> list = new MainBvaReportRecordDataAccess().SelectList();
                    MainDataSet ds = this.GetDataSetFromList(list);
                    rpt.SetDataSource(ds.Tables[0]);
                catch (Exception ex)
                    MessageBox.Show(ex.Message);
                view.ReportSource = rpt;
    The call to SetDataSource crashes without a catchable exception.  I have tried passing just the raw dataset (ds) to SetDataSource with the same results.  The dataset is an unbound set defined in DataSet1.xsd, and consists of string data types.  The list is populated by a stored procedure that is selecting from a view (if that helps).  I have tried running the report against the view itself (using the Database Expert to switch out between the dataset and the view), and the report will run, but only gets two records (there are 50 records in my test database).  I really need to be able to set the data source to a dataset I can control.  When completed this report will have several sub-reports, and I need to be able to populate them as well.  However, I can't get even the simple case to run.  Any help would be appreciated.

    OK, further digging got me a better answer about the exception.  The reason I wasn't getting any exception info is that it was looking in the wrong directory for the crdb_adoplus.dll.  It was looking for this under the "C:\Program Files\SAP BusinessObjects\SAP BusinessObjects Enterprise XI 4.0\win32_x86\dotnet1" directory. I copied the dll into that directory (I had to creat it on my machine), and that got me a more tracable error: "mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information."  Some digging around on that got me to the following solution.  I need to add the following to my *.exe.config file:
    <startup useLegacyV2RuntimeActivationPolicy="true">
      <supportedRuntime version="v4.0"/>
    </startup>
    That gets me over the SetDataSource hurdle.  Now, I am only seeing two records of the 50 in the dataset [sigh]

  • Failed to load database information.Error in File BillReport {Some numbers}.rpt

    Hi Team I am having problm with Crystal Report for Visual Studio 2013.
    I have developed windows application with Crystal Report and Visual Studio 2010.
    Now when i try to run same code in VS 2013 with Crystal report for VS 2013. i am getting following error.
    Failed to load database information.
    Error in File BillReport {A677B982-B8FC-4349-8BE6-9D1DA6B33521}.rpt:
    Failed to load database information.
    Source : "CrystalDecisions.ReportAppServer.DataSetConversion"
    I have used oledb connection to fill XML dataset.
    That dataset is binded to Crystal report at run time..
    Here is my code.
    string sqlstr = "";
                    sqlstr = "select * from billMaster where billid =  " + billId + " and merchantName = '"+merchantName+"' ";
    cmd = new OleDbCommand(sqlstr, m1.ccon);
                    if (m1.ccon.State == ConnectionState.Closed)
                        m1.ccon.Open();
                    OleDbDataAdapter da = new OleDbDataAdapter(sqlstr, m1.ccon);
                    BillPrint bp = new BillPrint();

    <startup useLegacyV2RuntimeActivationPolicy="true">
    </startup>
    is the solution man.
    Thanks a lot...
    I tried this one also..
    Try saving the DS ( bp ) to xml format and have a look at the data, it may be a data field type has changed with the new OLEDB driver in VS 2013. This may be what Dell is referring to...
    Try this:
    bp.WriteXml("c:\\sc.xml", XmlWriteMode.WriteSchema);
    Then set the report to the xml data source:
    System.Data.DataSet ds = new System.Data.DataSet();
    ds.ReadXml(@"C:\App_Data\sc.xml", XmlReadMode.ReadSchema);
    rpt.SetDataSource(ds);
    but it didn't help..
    anyway
    <startup useLegacyV2RuntimeActivationPolicy="true">
    </startup>
    this one is solution..

  • Dataset logon problem

    Post Author: yurluc
    CA Forum: .NET
    Hello,
    I did not work with VS2005 and Crystal reports Viewer before and now I have, in my opinion, a strange problem. I started to work on project that requires viewing a dataset into crystal report using a .NET object. The problem is that I have a dataset that disconnected from the database. When I run the app, Database login box pops up. Since I do not have any info on connection string, I do not have any info to set TableLogInfo object. So I am stuck with this message to input user name and password that I do not have. Is there any way to disable the pop up message?
    What is more interesting Is that if I use database file .XSD it is not require logon information.
    Here is my code.
              string&#91;&#93; Parm = new string&#91;3&#93; {"NULL","NULL","NULL"};           DataSet myData = RecSet.GetRecordset("sp_Get_Address", Parm);           ReportDocument rpt = new ReportDocument();
              rpt.Load(@"C:\Development\Reports\" + theRepName);           rpt.SetDataSource(myData.Tables&#91;0&#93;.DataSet);
              this.crvReportViewer.ReportSource = rpt;
    Any help will be greatly appreciated.
    Regards,   yurluc.

    Post Author: Argan
    CA Forum: .NET
    Did you design the report against the schema of the dataset you are passing?
    You have to do this and make sure that the dataset and report contain the exact same fields.

  • Using a Database View and Untyped Dataset

    Post Author: kramer9802
    CA Forum: .NET
    Product:Crystal Reports XI Release 2
    Version:
    Patches Applied:
    Operating System(s):XP
    Database(s):Oracle
    Error Messages: Steps to Reproduce: Normally, the reports we create are designed based on Oracle tables. Then the data source is set to a dataset I populate in code from a SQL statement. I know this isn't necessarily how it is done in the documentation, but it has been working. What I am trying to do now is use a database view to design the report and then populate the my dataset based on a query on the view for VB code. When I do that my dataset only has one row, but my report is building based on all the rows returned by the view (Thousands). The sql  is something like this  Select * From xyz_view where record_id= ('The record the user wants to see')   The view basically pulls back the data from several tables and also pulls back a few lookup tables that have description of value fields. I would use formula fields for the description but there is a lot records. I know that you can't pass a parameter into a view, so that is why I use select statement against the view to filter it down to the specific record I want. So I guess my question is why does build the report based on all the records from the view rather than all the one record in the Dataset? If I do the same thing but design the report based on a table or serveral tables, then the report only contains records from the dataset. I think I kind of know that the report is ignoring the dataset, but I guess I just need to know if there is an easy way to make this work or do I need to reconsider how I design and populate the reports. The reports are non-embedded based on a business requirement. let me know if this doesn't make sense or you need more details. Thanks Kramer

    Post Author: Argan
    CA Forum: .NET
    Honestly I do not know.
    This question is more of a design issue and would be better suited to Crystal Reports forum
    http://technicalsupport.businessobjects.com/cs/forums/13/ShowForum.aspx
    As an aside, technically speaking if you are using datasets then you should be designing the report against the schema of the dataset you are going to be passing, not the tables or storeprocs or views themselves.

  • Crystal Report generating data from incorrect data source

    In dealing with a recent post about an upgrade to Crystal XI R2 mixing badly with an old VS 2003 project ( Update to CR XI R2 and service pack 4 issues with VS 2003 ), I've been attempting a few things to get past the issues with missing parameters and so on.  I found that I actually was using a parameter in the report I was trying to run, so I assigned the proper value to said parameter, ran the report, and lo and behold all was well.  The data was coming back correctly, no errors, everything seemed fine.<br><br>
    Then I checked the results against the production environment of this application, hosted on a remote server, and was disappointed to find that the reports were now coming back blank.  After some deeper investigation, it turned out that the data it was retrieving was coming from my development server and not the production server like it had in the past.  As far as I can tell, it is completely ignoring the dataset that I'm assigning to the report object (which is filling with the correct data) and just running the query built into the report, which is connected via ODBC to my development server database.  I have no idea what this is going to do when the application is run from the production environment itself, as in, my customers running the application from their desktops, and I have no way of testing this.<br><br>
    I will fully admit that the report may be poorly designed, because then and surely enough now I'm no crystal expert, but as I said in my previous thread, this all worked fine until I upgraded to XI R2 for another project.  Essentially what I want is for the report to accept the dataset and display ONLY that data, and not run a query against the ODBC connection.  Is there some way to force this behavior?  Here's a sample of my code, if it helps:<br><br>
    ReportDocument myReport = new ReportDocument();<br>
    DataSet myData = new DataSet();<br>
    MySqlDataAdapter myAdapter;<br>
    myAdapter = new MySqlDataAdapter();<br><br>
    file_name = ApplicationMain.file_path"
    Files
    Invoice_"invoice_number+".pdf";<br>
    MySqlCommand cmd = generate_command(invoice_number, false);<br><br>
    myAdapter.SelectCommand = cmd;<br>
    myAdapter.Fill(myData,"X");<br><br>
    myReport.Load(ApplicationMain.file_path+"
    Files
    Invoice.rpt");<br><br>
    myReport.SetParameterValue("requ_id",this.ID);<br>
    myReport.SetDataSource(myData);<br>
    myReport.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, file_name);<br><br>
    It's all relatively simple, create a dataset, load the report, assign the dataset to the report, export to a PDF. 
    I've tried to reassign the report's connection to the currently connected database (code snippet below) but every time I end up getting a logon failed error message, even when I know for sure the login data is correct, and even when I'm just connecting to my local development server.<br><br>
    TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();<br>
    TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();<br>
    ConnectionInfo crConnectionInfo = new ConnectionInfo();<br>
    crConnectionInfo.ServerName = ApplicationMain.com_host;<br>
    crConnectionInfo.DatabaseName = ApplicationMain.com_database;<br>
    crConnectionInfo.UserID = ApplicationMain.com_username;<br>
    crConnectionInfo.Password = ApplicationMain.com_password;<br><br>
    foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in myReport.Database.Tables)<br>
    {<br>
         crtableLogoninfo = CrTable.LogOnInfo;<br>
         crtableLogoninfo.ConnectionInfo = crConnectionInfo;<br>
         CrTable.ApplyLogOnInfo(crtableLogoninfo);<br>
    }<br><br>
    I ran that after loading the report, but received a failed login error every time.  Any suggestions on how to proceed with this?  I'm at a loss because up until now I've never had a problem like this with a crystal report, they always just took the datasets I gave them without ever running anything else.

    After attempting quite a few of the proposed solutions, nothing seemed to be working.  Due to the limited usage and number of reports in my application, I decided to try recreating them from scratch (there are only 3 and 2 are nearly identical) using only the crystal 9 integrated designer in VS2003.  My initial testing has been successful, even using the same base query that the failing reports were using.
    Dropping everything and recreating all of ones reports is not the greatest solution, but at worst it's a few hours of tweaking, as opposed to days of frustration messing around trying to get the "corrupted" reports to work again.  Thank you again for your assistance.

  • Crystal Report Coming out Blank

    Hi Guys
    I have been struggling for days now with a my vb.net app that is using sql server as DB. I am creating a crystal report but it seems it always comes out blank when i use my dataset as the datasource. If i change the datasource to my-pc it all works fine
    but i dont want this as it will be using another server after deploying the app.
    I have created a CrystalReportViewer1 and a rptAllEmployeesSalaries.rpt crystal report .The report is displaying data from two tables which i used an INNER JOIN Select statement. This is my code on the form load event;
    Private Sub frmrptAllEmployees_Load(sender As Object, e As EventArgs) Handles Me.Load
            Dim rpt As New rptAllEmployeesSalaries 'The report created.         
            Dim myConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("TMS.My.MySettings.xConnectionString").ConnectionString)
            Dim MyCommand As New SqlCommand()
            Dim myDA As New SqlDataAdapter()
            Dim myDS As New xDataSet4 'The DataSet  created.  
            myConnection.Open()
            Try
                MyCommand.CommandText = "SELECT employeeWork_infor.jobTitle, employeeWork_infor.status, employeeWork_infor.branch, employeeSalaries.salary, employeeWork_infor.employeeSurname, employeeWork_infor.employeeName, employeeWork_infor.employeeNo
    FROM employeeWork_infor FULL JOIN employeeSalaries ON employeeWork_infor.employeeID = employeeSalaries.employeeID"
                MyCommand.CommandType = CommandType.Text
                myDA.SelectCommand = MyCommand
                MyCommand.Connection = myConnection
                myDA.Fill(myDS, "employeeWork_infor")
                myDA.Fill(myDS, "employeeSalaries")
                rpt.SetDataSource(myDS)
                CrystalReportViewer1.RefreshReport()
                CrystalReportViewer1.ReportSource = rpt
            Catch Excep As Exception
                MessageBox.Show(Excep.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try
            myConnection.Close()
        End Sub
    End Class
    Please help my report always comes out blank im not sure why
    Trevor

    Thanx Venkat786
    1) i tried Running my T-sql query in SSMS and it does give me the data that i     want.
    2) I put the "myDS.WriteXml("c:\temp\result.xml")" before my set datasource line inside my code and it does write all the retrieved data to the result.xml file.
    3)When the designer previews the report it populates it with what looks like sample data and not data from my DB.
    From steps 1 & 2 it looks like all is working fine not sure if the result im getting on 3 is ok, but still after all this my report is still coming out blank.
    Would really appreciate it if you continue to assist...
     

  • Report Document not show on Crystal Report Viewer in C#

    My program is modified from VB.NET. Now I struck with Crystal Report that Crystal Report Viewer didn't show Report Document.
    Printing code is composed of two forms. One assign parameters and objects need. Other is Crystal Report Viewer form, CrystalReportForm. Last one run report by parameter from the first.
    When run this code that it didn't found any error but the problem is no report show on Crystal Report Viewer on second form. It just blank Crystal Report Viewer. There arm't any message response.
    Here is my code.
    // report caller form.
    private void Print()
       CrystalReportForm rptForm = new CrystalReportForm();
       string[] strtbl;
      strtbl = new string[1];
       string[] strqry;
      strqry = new string[1];
       // prepare var
       string myqry;
       string myrpt;
       // Pass The Table That you used in the crystal Report
      strtbl[0] = "r_receipts";
       // Pass the Query
      myqry = "SELECT * FROM r_receipts";
      myrpt = "rptReceipts.rpt";
      strqry[0] = myqry;
       //Pass For Mdi True
      rptForm.MdiParent = this.ParentForm;
      rptForm.ViewReport(myrpt, strtbl, strqry, "");
       //Parameter Value It is Optional
      rptForm.Show();
    // Crytal Report Viewer form.
    public void ViewReport(string ReportName , string[] TableName, string[] QueryString , string Parameter = "")
       //Me.MdiParent = mainpage;
       if (TableName.Length  != QueryString.Length  )
       MessageBox.Show("Passed Variable Are Not Correct", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
       return;
       CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
       CrystalDecisions.Windows.Forms.CrystalReportViewer crv  = new CrystalDecisions.Windows.Forms.CrystalReportViewer();
      crv.ActiveViewIndex = 0;
      crv.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
      crv.ToolPanelView = CrystalDecisions.Windows.Forms.ToolPanelViewType.None;
      crv.Dock = System.Windows.Forms.DockStyle.Fill;
      crv.Location = new System.Drawing.Point(0, 0);
      crv.Name = "CrystalReportViewer";
       MySqlDataAdapter at =new MySqlDataAdapter();
       DataSet ds = new DataSet();
       for (int i = 0; i < TableName.Length; i++)
      at = GetDataAdeptor(QueryString[i]);
      at.Fill(ds, TableName[i]);
       string rptPath  = "";
      rptPath = Application.StartupPath + "\\" + ReportName;
      rpt.Load(rptPath);
      rpt.SetDataSource(ds);
       if (Parameter != "")
      rpt.SetParameterValue(0, Parameter);
      crv.ReportSource = rpt;
      crv.Refresh();
       //CrystalReportViewer.DataBind();
       //Me.Panel1.Controls.Add(CrystalReportViewer);
       Panel panel1 = new Panel();
      panel1.Controls.Add(crv);

    Hi Bhushan,
    It's not yet fixed. My dataset (ds) can't bine to DataGridView as
    DataGridView1.DataSource = ds
    But it could do like this
    DataGridView1.DataSource = ds.Tables[0];
    When I bine to Crystal Report Viewer setdatasource
    CrystalReportViewer1.setdatasource = ds.Tables[0];
    It still not work, anyway you suggest let me in the right way. I very confuse the thing I fix to bine to DataGridView
    Thank,
    Chaiwat

  • Programmatically adding a Word Document or PDF to a crystal report

    I am using Crystal XI for windows.  I have a VB.Net windows application that I am trying to insert a Word Document and/or PDF into.  I want to programmatically be able to add any file(s) to a crystal report.  Is there any sample code or guidance that can show me how to programmically add a file to a report?
    In the user interface, the user can click on unlimited number of PDFs, Word Documents... to insert into a Crystal Report.  Is this possible?   If so, please show steps and some sample code how to do this.
    Kind Regards,
    Jeff

    In this example, the ReportAppFactory gets initialized with the instance from the session object... If I am doing this in windows (not a web application), how would this change it if this is a windows application with no session object?
    I am connecting against an  ADO.Net (XML) file on the same computer - no connection information required... I just want to open the report file, SetDataSource to a dataset ...then do the other stuff in the example.  I think after I get past connecting to the data and opening the report, the rest of working with sections and adding ole objects I can get from the examples.  All of the sample code that I found are web based and don't show how to connect if you are windows based - not over a web page.
    I am not using a CMS or anything web / network based... I just want to connect to a local XML file that was generated from Visual Studio .Net 2005.   The example below is one of the Crystal Samples... they are all web based samples.  ...I am looking for a windows based sample to see how to connect and open a report file.
    Example:
            If Not (Session("boEnterpriseSession") Is Nothing) Then
                boEnterpriseSession = CType(Session("boEnterpriseSession"), CrystalDecisions.Enterprise.EnterpriseSession)
            Else
                'Log on to the Enterprise CMS
                boSessionMgr = New CrystalDecisions.Enterprise.SessionMgr
                boEnterpriseSession = boSessionMgr.Logon(Request.QueryString.Item("username"), Request.QueryString.Item("password"), Request.QueryString.Item("cms"), Request.QueryString.Item("authtype"))
                Session.Add("boEnterpriseSession", boEnterpriseSession)
            End If
            'get report object from session or create a new report object
            If Not (Session("boReportClientDocument") Is Nothing) Then
                boReportClientDocument = CType(Session("boReportClientDocument"), CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocument)
            Else
                boEnterpriseService = boEnterpriseSession.GetService("", "InfoStore")
                boInfoStore = New CrystalDecisions.Enterprise.InfoStore(boEnterpriseService)
                boReportName = "SimpleRCAPIReport.rpt"
                'Retrieve the report object from the InfoStore, only need the SI_ID for RAS
                boQuery = "Select SI_ID From CI_INFOOBJECTS Where SI_NAME = '" + boReportName + _
                 "' AND SI_Instance=0"
                boInfoObjects = boInfoStore.Query(boQuery)
                boInfoObject = boInfoObjects(1)
                boEnterpriseService = Nothing
                'Retrieve the RASReportFactory
                boEnterpriseService = boEnterpriseSession.GetService("RASReportFactory")
                boReportAppFactory = CType(boEnterpriseService.Interface, CrystalDecisions.ReportAppServer.ClientDoc.ReportAppFactory)
                'Open the report from Enterprise
                boReportClientDocument = boReportAppFactory.OpenDocument(boInfoObject.ID, 0)
                'First determine where to add - in this case the details Area
                boArea = boReportClientDocument.ReportDefController.ReportDefinition.DetailArea
                'Create the new section object
                boSection = New CrystalDecisions.ReportAppServer.ReportDefModel.Section
                'Set the properties for the section
                boSection.Kind = CrystalDecisions.ReportAppServer.ReportDefModel.CrAreaSectionKindEnum.crAreaSectionKindDetail
                boSection.Name = "Detail2"
                boSection.Height = 1000
                boSection.Width = 11520
                'Now add the section
                boReportClientDocument.ReportDefController.ReportSectionController.Add(boSection, boArea, -1)
                'Add the reportClientDocument to session
                Session.Add("boReportClientDocument", boReportClientDocument)
            End If
    Thanks,
    Jeff
    Edited by: Jeff Dressing on Aug 20, 2008 10:48 AM

  • Crystal reports "Database login failed" when using push method

    I have a web application (ASP.NET, .NET v3.5), that pushes data to a CR 2008 report. On two servers one of the three reports returns a "Database login failed" error. I am stumped since there is no login, it's push not pull; in addition the problem is hard to debug since it works fine from my developers workstation. I have "updated" the xsd in that report, reinstalled the app, etc., non of which helped. If anyone has a solution or even ideas I'd appreciate the help.

    What about following the troubleshooting steps as described in the blog;
    Create an XML file off of your dataset. Make sure this is done just before you set the dataset to the report:
                rpt.Load(rptPath)
    myDataset.WriteXml(xmlPath, XmlWriteMode.WriteSchema)
    rpt.SetDataSource(myDataset)
    Copy the above created XML to your development system
    Open the problem report in the Crystal Reports designer
    In the Desigger, go to the Database menu and select u201CSet Datasource Locationu201D
    In the u201CReplace with:u201D pane, expand the u201CCreate New Connectionu201D folder.
    Double click the u201CADO .NET (XML)u201D icon
    Browse to the location of the XML file you created in step (1)
    Click on the path to the XML. The <Update> button should enable
    Click on the <Update> button
    Typically, either of the following will happen:
    You will get a u201CMap Fieldsu201D dialog. This indicates that the XML written off of your dataset does not match what the report is expecting. This may be due to incorrect fields name, incorrect field type, etc. You will now need eliminate the difference.
    Incorrect data or no data. There is an issue with your dataset and you need to determine why the data is not present in your dataset. Looking at the XML may be a good place to start.
    Ludek

  • How to print the report directly without previewing (report viewer) using c# windows application

    Hi,
    Currently, we are using crystal report to all of our reporting applications, but since I/users have encountered some issues about CR's speed to load only a simple report, maybe it is now time for us to adopt a new reporting environment in which I think SSRS
    can fill this problem.
    To start with, I have here a sample code, that uses the crystal report to print the report directly without previewing:
    csCashInvoiceCal csCashCal; --Crystal report name .rpt
    dsCsReceipt dsCs; --created dataset
    DataTable u;
    DataRow s;
    private System.Drawing.Printing.PrintDocument printDocument1;
    private System.Windows.Forms.PrintDialog printDialog1;
    ParameterValues paramValue;
    ParameterDiscreteValue discreteValue;
    ParameterFieldDefinition fieldDefinition;
    private void btnPrint_Click(object sender, EventArgs e)
    this.Cursor = Cursors.WaitCursor;
    loadReceipt2();
    print2();
    csCashCal.Close();
    this.Cursor = Cursors.Default;
    private void loadReceipt2()
    dsCs = new dsCsReceipt(); --created dataset
    u = dsCs.Tables.Add("DtCsReceipt");
    u.Columns.Add("Qty", Type.GetType("System.String"));
    u.Columns.Add("UOM", Type.GetType("System.String"));
    u.Columns.Add("Description", Type.GetType("System.String"));
    u.Columns.Add("UnitPrice", Type.GetType("System.String"));
    u.Columns.Add("Discount", Type.GetType("System.String"));
    u.Columns.Add("Amount", Type.GetType("System.String"));
    try
    for (int i = 0; i < dgvDesc.Rows.Count - 1; i++)
    s = u.NewRow(); double.TryParse(dgvDesc.Rows[i].Cells[Discount2.Name].Value.ToString(), out discount);
    s["Qty"] = double.Parse(dgvDesc.Rows[i].Cells[Qty.Name].Value.ToString());
    s["UOM"] = dgvDesc.Rows[i].Cells[Uom2.Name].Value.ToString();
    s["Description"] = invcode + dgvDesc.Rows[i].Cells[Description.Name].Value.ToString();
    s["UnitPrice"] = dgvDesc.Rows[i].Cells[UnitPrice.Name].Value.ToString();
    if (discount != 0)
    s["Discount"] = "(" + string.Format("{0:0.##}", discount) + "%)";
    else
    s["Discount"] = "";
    s["Amount"] = dgvDesc.Rows[i].Cells[Amount2.Name].Value.ToString();
    u.Rows.Add(s);
    catch (Exception) { }
    csCashCal = new csCashInvoiceCal();
    csCashCal.SetDataSource(dsCs.Tables[1]);
    //csCashCal.Refresh();
    loadParameter2();
    private void loadParameter2()
    ParameterFieldDefinitions paramFieldDefinitions;
    paramValue = new ParameterValues();
    discreteValue = new ParameterDiscreteValue();
    paramFieldDefinitions = csCashCal.DataDefinition.ParameterFields;
    discreteValue.Value = date;
    fieldDefinition = paramFieldDefinitions["Date"];
    commonParam();
    discreteValue.Value = txtcsno.Text;
    fieldDefinition = paramFieldDefinitions["InvoiceNo"];
    commonParam();
    discreteValue.Value = txtNameTo.Text;
    fieldDefinition = paramFieldDefinitions["CustomerName"];
    commonParam();
    discreteValue.Value = txtAdd.Text;
    fieldDefinition = paramFieldDefinitions["CustomerAddress"];
    commonParam();
    ------other parameters----
    private void commonParam()
    paramValue.Clear();
    paramValue.Add(discreteValue);
    fieldDefinition.ApplyCurrentValues(paramValue);
    private void print2()
    using (printDocument1 = new System.Drawing.Printing.PrintDocument())
    using (this.printDialog1 = new PrintDialog())
    //this.printDialog1.UseEXDialog = true;
    this.printDialog1.Document = this.printDocument1;
    DialogResult dr = this.printDialog1.ShowDialog();
    if (dr == DialogResult.OK)
    int nCopy = this.printDocument1.PrinterSettings.Copies;
    int sPage = this.printDocument1.PrinterSettings.FromPage;
    int ePage = this.printDocument1.PrinterSettings.ToPage;
    string PrinterName = this.printDocument1.PrinterSettings.PrinterName;
    try
    csCashCal.PrintOptions.PrinterName = PrinterName;
    csCashCal.PrintToPrinter(nCopy, false, sPage, ePage);
    printcount++;
    //saveCountPrint();
    catch (Exception err)
    MessageBox.Show(err.ToString());
    This is only a simple sales receipt application that uses dgv and textboxes to push its data to dataset to the crystal report, a simple one but there are instances that it is very slow.
    But I'm having trouble implementing this using SSRS, since I'm only new to this one, wherein I created the report using report wizard, with two button options inside the form for print preview or direct print selection. Actually, it is very easy to implement
    with print preview because it uses reportviewer. My problem is that how can I print the report directly without using a reportviewer?
    So here is my code so far which I don't know what's next:
    private void button2_Click(object sender, EventArgs e)
    this.Cursor = Cursors.WaitCursor;
    loadReceipt3();
    //print3();
    this.Cursor = Cursors.Default;
    ReportParameter[] parameter = new ReportParameter[11];
    private void loadParameter3()
    parameter[0] = new ReportParameter("InvoiceNo", txtcsno.Text);
    parameter[1] = new ReportParameter("Date", date);
    parameter[2] = new ReportParameter("CustomerTin", txtTin.Text);
    parameter[3] = new ReportParameter("CustomerName", txtNameTo.Text);
    parameter[4] = new ReportParameter("CustomerAddress", txtAdd.Text);
    parameter[5] = new ReportParameter("Agent", agent);
    parameter[6] = new ReportParameter("Discount", "Discount: ");
    parameter[7] = new ReportParameter("TotalDiscount", lblDiscount.Text + "%");
    parameter[8] = new ReportParameter("TotalSales", rdtotal);
    parameter[9] = new ReportParameter("Tax", rdtax);
    parameter[10] = new ReportParameter("TotalAmount", rdnet);
    private void loadReceipt3()
    DataSet dsrs = new DataSet();
    DataTable dtrs = new DataTable();
    DataRow drs;
    dtrs.Columns.Add("Qty", Type.GetType("System.String"));
    dtrs.Columns.Add("UOM", Type.GetType("System.String"));
    dtrs.Columns.Add("Description", Type.GetType("System.String"));
    dtrs.Columns.Add("UnitPrice", Type.GetType("System.String"));
    dtrs.Columns.Add("Discount", Type.GetType("System.String"));
    dtrs.Columns.Add("Amount", Type.GetType("System.String"));
    try
    for (int i = 0; i < dgvDesc.Rows.Count - 1; i++)
    drs = dtrs.NewRow();
    drs["Qty"] = double.Parse(dgvDesc.Rows[i].Cells[Qty.Name].Value.ToString());
    drs["UOM"] = dgvDesc.Rows[i].Cells[Uom2.Name].Value.ToString();
    drs["Description"] = invcode + dgvDesc.Rows[i].Cells[Description.Name].Value.ToString();
    drs["UnitPrice"] = dgvDesc.Rows[i].Cells[UnitPrice.Name].Value.ToString();
    if (discount != 0)
    drs["Discount"] = "(" + string.Format("{0:0.##}", discount) + "%)";
    else
    drs["Discount"] = "";
    drs["Amount"] = dgvDesc.Rows[i].Cells[Amount2.Name].Value.ToString();
    dtrs.Rows.Add(s);
    catch (Exception) { }
    int addtlRow = 7;
    if (addtlRow > (count - 1))
    addtlRow = addtlRow - (count - 1);
    for (int i = 0; i < addtlRow; i++)
    dtrs.Rows.Add();
    loadParameter3();
    LocalReport localreport = new LocalReport();
    localreport.SetParameters(parameter);
    localreport.DataSources.Clear();
    localreport.DataSources.Add(new ReportDataSource("dsSalesReceiptSsrs", dtrs));
    localreport.Refresh();
    //what's next....
    So what's next after local..refresh()? Actually, I have googled a lot but I didn't found the exact solution that I'm looking for which confuses me a lot.
    Anyway I'm using VS 2010 with sql server 2012 express.
    You're help will be greatly appreciated.
    Thank you,
    Hardz

    After some further studies with ReportViewer controls and with the use of this tutorial @ : http://msdn.microsoft.com/en-us/library/ms252091.aspx, which helps me a lot on how to print a report without using a report viewer, I found out what is missing
    with my code above and helps solve my question.
    Here's the continuation of the code above:
    private void loadReceipt3()
    loadParameter3();
    LocalReport localreport = new LocalReport();
    localreport.ReportPath = @"..\..\SsrsCashReceipt.rdlc";
    localreport.SetParameters(parameter);
    localreport.DataSources.Clear();
    localreport.DataSources.Add(new ReportDataSource("dsSalesReceiptSsrs", dtrs));
    Export(localreport);
    print4();
    private IList<Stream> m_streams;
    private int m_currentPageIndex;
    private void Export(LocalReport report)
    string deviceInfo =
    @"<DeviceInfo>
    <OutputFormat>EMF</OutputFormat>
    <PageWidth>8.5in</PageWidth>
    <PageHeight>11in</PageHeight>
    <MarginTop>0.25in</MarginTop>
    <MarginLeft>0.25in</MarginLeft>
    <MarginRight>0.25in</MarginRight>
    <MarginBottom>0.25in</MarginBottom>
    </DeviceInfo>";
    Warning[] warnings;
    m_streams = new List<Stream>();
    report.Render("Image", deviceInfo, CreateStream,
    out warnings);
    foreach (Stream stream in m_streams)
    stream.Position = 0;
    private void print4()
    if (m_streams == null || m_streams.Count == 0)
    throw new Exception("Error: no stream to print.");
    PrintDocument printDoc = new PrintDocument();
    PrintDialog printDlg = new PrintDialog();
    printDlg.Document = printDoc;
    DialogResult dr = printDlg.ShowDialog();
    if (dr == DialogResult.OK)
    if (!printDoc.PrinterSettings.IsValid)
    throw new Exception("Error: cannot find the default printer.");
    else
    printDoc.PrintPage += new PrintPageEventHandler(PrintPage);
    m_currentPageIndex = 0;
    printDoc.Print();
    Dispose();
    public void Dispose()
    if (m_streams != null)
    foreach (Stream stream in m_streams)
    stream.Close();
    m_streams = null;
    private Stream CreateStream(string name, string fileNameExtension, Encoding encoding, string mimeType, bool willSeek)
    Stream stream = new FileStream(name + "." + fileNameExtension,
    FileMode.Create);
    m_streams.Add(stream);
    return stream;
    private void PrintPage(object sender, PrintPageEventArgs ev)
    Metafile pageImage = new
    Metafile(m_streams[m_currentPageIndex]);
    // Adjust rectangular area with printer margins.
    Rectangle adjustedRect = new Rectangle(
    ev.PageBounds.Left - (int)ev.PageSettings.HardMarginX,
    ev.PageBounds.Top - (int)ev.PageSettings.HardMarginY,
    ev.PageBounds.Width,
    ev.PageBounds.Height);
    // Draw a white background for the report
    ev.Graphics.FillRectangle(Brushes.White, adjustedRect);
    // Draw the report content
    ev.Graphics.DrawImage(pageImage, adjustedRect);
    // Prepare for the next page. Make sure we haven't hit the end.
    m_currentPageIndex++;
    ev.HasMorePages = (m_currentPageIndex < m_streams.Count);
    Thank you very much for this wonderful tutorial. :)

  • Migrating from Crystal Reports 9 to 2008 Issue

    Hello,
    We have quite a few reports in our product that were built of of tables in a database.  One report in question has fields from two tables. We used to load the report in VB6, and set the SQLQueryString property on the report equal to a select statement to select specific rows for the report.
    We are trying to change these reports to use DataSets.  The idea is to populate a dataset with all the data the report needs, and set that as the data source.  No matter what I do, i cannot seem to get data to show up in the report.  I've tried creating a dataset with two tables, named identically to the tables we were using out of the database, and then filling the dataset with ALL the records from both tables.  Then I tried creating a dataset with one table, with columns from both tables, neither seem to work.
    After creating the dataset, we are using the Set datasource location in Crystal, and updating it to use the Dataset we created.  I've verified the dataset has rows, and everything seems like it -should- work fine, but no data is populated.
    I did notice that when changing the datasource location to the dataset, the Tables retained their old names with the name of the table in the dataset in parenthesis.  I thought about merging all the fields from both tables into just one table from the dataset, but could not find an easy way to do this without having to completely redesign the report.
    Any suggestions would be greatly appreciated. Thanks!

    Moved your post to the .NET SDK forum.
    Ah, that will be a problem, CR no longer allows editing the SQL statement so those old reports are going to cause problems.
    First also, you did not say but you can't use the RDC or OCX or CR 2008 in .NET 2010
    Go to this page and download the CR for VS 2010 installer: http://www.sdn.sap.com/irj/boc/crystalreports-dotnet
    Bottom of the page: http://downloads.businessobjects.com/akdlm/cr4vs2010/CRforVS_13_0_1.exe gets CR installed into VS 2010.
    Then you can use RAS which is the replacement for the OCX and RDC.
    Then if you need .NET samples see this page to get you going:
    http://wiki.sdn.sap.com/wiki/display/BOBJ/NETRASSDK+Samples#NETRASSDKSamples-Exporting%2FPrinting
    A couple of ways to possibly fix those legacy reports.
    General over view is to:
    1. Rebuild your reports from scratch and use your XML files as the data source
    2. Rebuild your reports and use the DataSet as your report source ( BIG warning here, DS's are limited to the amount of data so better to use XML as the source )
    3. Hit the Database directly and use Record Selection API's to add your filters to the data
    4. Use database Command which allows you to enter SQL directly and edit it in code.
    All methods are likely going to have problems due to you altering the SQL manually.
    The replacement for edited SQL in legacy reports is to use a Command Object, you see this in the database wizard.
    I have code that will convert a report based on 1 or 2 tables and convert it to a Command Object as the data source but this may not work for you depending on what the report started with.... More tables and it won't work.
    Not going to suggest DS's as they will cause problem for the end user when they start using your app to archive the database.
    For XML, use the below code to get your data into a DS and then save the DS as a XML file with the Schema.
    Once connected to your data sources use this code to export/save the DS to XML format:
    // this writes to the data and schema to a file
                ds.WriteXml("c:
    sc.xml", XmlWriteMode.WriteSchema);
    // this sets the report data source to the DS or XML file
                rpt.SetDataSource(ds);
    Once you have it save in XML format you can now create your reports of the XML file, Set Location likely won't work for you.
    You can then not use DS's in your app and simply dump the database fields you are using into the XML. Once this is done simply updating the XML file will refresh the data in the report.
    For using Command Objects
    You can get the SQL from your old reports and then set the SQL of your Command using RAS. I've never tried this with edited Legacy Reports but should work as long as you don't use or try to update the Legacy report in code.
    Once you do manually re-create the legacy reports or possibly using the Table -> Command code you can then modify the SQL to follow your original report progression in your legacy app.
    Let me know which route you want to go and I'll paste in the code to get you started...
    Thank you
    Don

  • How to create an editable previewable report?

    The Situation (the report is  CrystalReports.Engine.ReportDocument):
    I load the report (.Load(Template)) and  set data (.SetDataSource(DataTable)). I save the report (.SaveAs or .Export). The Template does not necessary contains fields in DataTable used as datasource.
    When I open the created report in "Crystal Reports 2011" the report preview is shown.  When I switch to the design tab I can drag fields to the report, but when I switch to the preview again a dialog asking for ado.net xml datafile is shown and when canceled (I have no datafile) empty preview is shown. In Visual Studio 2010 (CRVS 2010?) I see the preview when I cancel the dialog and click the design and  the preview again.
    The Question:
    Is it possible to create a report containing data with the preview working after report is edited?
    Note:
    I can achieve the desired behavior with external data file, but this soulution is not very convenient.

    Ah... that helps a lot...
    A couple of ways to go about this. From your template report compare the fields that exist in the report with those your Query has and add them into the Report. You can use the Command Object to append the fields and then the report will need to be refreshed against the XML file. In this case though the report will need to be ran again.
    Another option is to export your data from your Query into a DataSet and simply .setlocation to the DS, great for small amounts of data, less than 2K rows or so but you'll have to test for the limits.
    Another option is to to use RAS to completely create the report from nothing. See these samples on how to:
    http://wiki.sdn.sap.com/wiki/display/BOBJ/CrystalReportsSDKSampleApplications
    Bottom line is if you change the fields in a report it is going to have to be refreshed so the report can add/update the field reference list saved in the RPT file. If they don't match CR will simply delete all fields it can't match up.
    If using RAS to Create the report and set it to the new field list then you can build your own "Report Designer"
    As for running the Query again, that depends on how and where the data exists. If you save your date results into an XML file then it won't hit the DB again.
    This will generate the XML file:
                ds.WriteXml(@"D:\Atest\list_of_workflows.xml");
                ds.WriteXmlSchema(@"D:\Atest\list_of_workflows.xsd");
    Then load the XML file into a Dataset and then simply use:
    rpt.SetDataSource(ds);
    To set the Report to the XML file.
    XML is the preferred way and it doesn't have any memory limitations as Active DataSets do. ( MS limitation due to security, CR can't access the original so we have to make a copy which effectively doubles the amount of memory required )
    Don

  • Setting the sql statement

    http://www.egbolig.dk/drift_bo_syd.rpt (HERE IS THE REPORT)
    We are using SAP Crystal Report .NET Runtime files (http://scn.sap.com/docs/DOC-7824 newest version 13.0.9.1312) in our web asp.net application. Everything have been working fine, but we have can into problems when showing the certain kinda reports.
    In our code get the reports sql statement using getSQLStatement.
    Dim gp As New GroupPath() Dim sql As String = report.ReportClientDocument.RowsetController.GetSQLStatement(gp)
    This will get the sql, and we use this sql (getSqlStatement) and attach a sql WHERE clause from the code to only get a certain number of records.
    The report Drift_bo_syd.rpt has 5 tables, and the following sql statement. 
    Database/Show Sql Statement
    SELECT "rekvstam"."Sel", "rekvstam"."Afd", "rekvstam"."Levadresse", "rekvstam"."Rekvisition", "rekvstam"."Lejemaal", "rekvstam"."Lejer", "rekvstam"."Udfoertaf", "rekvstam"."Udfoertdato", "rekvstam"."Krit", "Selskab"."Adresse", "Selskab"."Postby", "Selskab"."Tlf", "Selskab"."Fax", "rekvstam"."Kontor", "rekvstam"."Hjemme", "rekvstam"."Rekvdato", "rekvstam"."Aftale", "rekvstam"."InitialRet", "rekvstam"."Arbejde", "kreditor"."Att", "rekvstam"."Konto", "Selskab"."Navn", "Selskab"."Email", "Interessentadresse"."Navn", "Interessentadresse"."Adresse", "Interessentadresse"."Postby", "Interessentadresse"."Email1", "Interessentadresse"."Telefon_Fax", "Interessentadresse"."Type", "Interessentadresse"."Tlf1", "rekvstam"."tlfLejer", "kreditor"."Kred", "Interessentadresse"."Interessentnr" FROM  (("Rekvstam" "rekvstam" INNER JOIN "Selskab" "Selskab" ON "rekvstam"."Sel"="Selskab"."Sel") LEFT OUTER JOIN "Kreditor" "kreditor" ON "rekvstam"."Kred"="kreditor"."Kred") INNER JOIN "Interessentadresse" "Interessentadresse" ON "kreditor"."Interessentnr"="Interessentadresse"."Interessentnr" WHERE  "Interessentadresse"."Type"='K' 
    But if we run the report from our asp.net code, we get the following error: 
    Cannot determine the queries necessary to get data for this report. Failed to retrieve data from the database. Error in File Drift_Bo_Syd {97FED382-1BAC-4DB1-970F-9E098ECE28F1}.rpt: Failed to retrieve data from the database.
    After a long time searching for a solution, we found out that if we place the column kred from the kreditor table on the report, the report will work. (field explorer / database fields / kreditor (table) / kred (column)
    Very important is that the field "kreditor.kred" is a primary key of the table kreditor, and also used in the linking.!
    (We can get the report to work if we call the sql statement with the "kreditor"."kred" in the SELECT statement.
    SELECT "kreditor"."kred", "rekvstam"."Sel", "rekvstam"."Afd", "rekvstam"."Levadresse", "rekvstam"."Rekvisition", "rekvstam"."Lejemaal", "rekvstam"."Lejer", "rekvstam"."Udfoertaf", "rekvstam"."Udfoertdato", "rekvstam"."Krit", "Selskab"."Adresse", "Selskab"."Postby", "Selskab"."Tlf", "Selskab"."Fax", "rekvstam"."Kontor", "rekvstam"."Hjemme", "rekvstam"."Rekvdato", "rekvstam"."Aftale", "rekvstam"."InitialRet", "rekvstam"."Arbejde", "kreditor"."Att", "rekvstam"."Konto", "Selskab"."Navn", "Selskab"."Email", "Interessentadresse"."Navn", "Interessentadresse"."Adresse", "Interessentadresse"."Postby", "Interessentadresse"."Email1", "Interessentadresse"."Telefon_Fax", "Interessentadresse"."Type", "Interessentadresse"."Tlf1", "rekvstam"."tlfLejer", "kreditor"."Kred", "Interessentadresse"."Interessentnr" FROM  (("Rekvstam" "rekvstam" INNER JOIN "Selskab" "Selskab" ON "rekvstam"."Sel"="Selskab"."Sel") LEFT OUTER JOIN "Kreditor" "kreditor" ON "rekvstam"."Kred"="kreditor"."Kred") INNER JOIN "Interessentadresse" "Interessentadresse" ON "kreditor"."Interessentnr"="Interessentadresse"."Interessentnr" WHERE  "Interessentadresse"."Type"='K'
    But it should not be necessary to include this field (which is the primary key and used in linking the report) in the sql statement,
    BECAUSE it is not used in the report. So maybe this is a bug?
    It has not been necessary in RDC Crystal Report or RAS Crystal Report in a classic asp envoriment.
    Here is the code we use to set the reports SQL Statement)
    Try
    Dim conn As New SqlConnection(connString)
    conn.Open()
    Dim sd As New SqlDataAdapter(New SqlCommand(nySQL, conn))
    Dim ds As New Data.DataSet()
    Dim navn As String = report.Database.Tables.Item(0).Name
    sd.Fill(ds, navn)
    report.SetDataSource(ds)
    conn.Close()
    Catch ex As Exception
    Throw
    End Try

    Hi Jan
    I understand your problem completely but we have asked  R&D to be able to edit the SQL and they explained due to how the report Engine works it's simply not possible anymore. It would take a complete rewrite in all of our DB drivers and query dll's to be able to allow it. They did that in CR 9 when they rewrote the DB drivers and removed the SQL part of the code into separate dll's and that is when the ability was removed, it's been that way ever since.
    One possibility is to get the SQL from the Report and then connect to your DB using a .NET and if the results from the SQL is less than 5K rows and not too many columns you could then set the Report data source to a Dataset.
    As long as all of the field names are the same CR will run the report using this work flow.
    For data larger than 5K rows, limit is due to memory resources, you could save the DS to an XML file and then set the reports data source to the XML file. We've seen 100meg XML's used so the amount of data should not be a problem, but of course there are limits to everything so test...
    This should not affect performance much.
    So the work flow would be:
    Load the report
    Get the SQL Statement
    Paste it into a Dataset Query
    Something like this should get you started:
    //string connString = "Provider=SQLOLEDB;Data Source=MySQLServer;Database=xtreme;User ID=sa;Password=pw";
    string connString = "Provider=SQLNCLI10;Server=MySQLServer;Database=xtreme;User ID=sa;Password=pw";
    Detail"".""Quantity"" FROM   ""xtreme"".""dbo"".""Orders Detail"" ""Orders Detail""";
    string sqlString = @"SELECT top 10*  FROM  ""xtreme"".""dbo"".""Financials"" ""Financials""";
    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("Financials");
    //DataTable dt2 = new DataTable("Orders Detail");
    oleAdapter.Fill(dt1);
    //oleAdapter2.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]); // incremtent [0] for more than 1 table.
        rpt.SetDataSource(ds);
    catch (Exception ex)
        MessageBox.Show("ERROR: Schema Mismatch. Error reported by CR: " + ex.Message);
    //Now check for subreport and set to same DS
    foreach (CrystalDecisions.CrystalReports.Engine.Section section in rpt.ReportDefinition.Sections)
        foreach (CrystalDecisions.CrystalReports.Engine.ReportObject reportObject in section.ReportObjects)
            if (reportObject.Kind == ReportObjectKind.SubreportObject)
                CrystalDecisions.CrystalReports.Engine.SubreportObject subReport = (CrystalDecisions.CrystalReports.Engine.SubreportObject)reportObject;
                CrystalDecisions.CrystalReports.Engine.ReportDocument subDocument = subReport.OpenSubreport(subReport.SubreportName);
                subDocument.SetDataSource(ds);
    And for XML it would use this part, not above I am saving the data and structure in the XML file so it should match what is in the report:
    foreach (CrystalDecisions.CrystalReports.Engine.Table rptTable in rpt.Database.Tables)
        try
            rptTable.Location = btrDataFile.ToString(); // @"D:\Atest\" + rptTable.Location + ".xml";
        catch (Exception ex)
            MessageBox.Show("ERROR: " + ex.Message);
    Only issue you may run into is sometimes XML does not have a direct field type and your original data source but you'll get an error if that happens which could be trapped and handled.
    If you have a report that only uses 2 tables I do have code that will convert it to use a Command Object. That is the limit the engine is capable of, there is a lot of logic to be able to do this in CRD and the SDK so that is all we could get for now.
    I hope that helps
    Don

Maybe you are looking for