Get crystal report data into XML format somehow using VB.NET

Posted on 2004-11-30
Medium Priority
Last Modified: 2007-12-19
This is sort of a repost but a little more educated this time... I have crystal reports that I want to get into XML format.  I can achieve this using CRAXDRT COM object.  Using all this stuff: CrystalDecisions.CrystalReports.Engine, CrystalDecisions.ReportSource, CrystalDecisions.Shared.

The reason I want to use the .NET parts is because I get a bizarre error message sometimes when trying to export to XML in CRAXDRT:  -2147184634  This property is currently in a read-only state and cannot be modified.  This only happens when I try to filter by date... I think.  I cannot reproduce this error all the time.  It craps out pretty randomly and I cannot figure out why.  No incidents for 3 weeks and then I can't get the app to run for a week.

CRAXDRT has an XML export method built in and it is mind boggling that the .NET component does not.  I really think there should be a way to do this and I am going crazy because I have pretty much written off using CRAXDRT since I cannot figure out for the life of me what the issue is.  If there is an extra component that I need to use or could buy, please inform me as I am scared I might start crying at work int he next few days if this doesen't work for me.

It's really not that bad but getting close.
My .NET component code works fine and I havent gotten any error messages yet, I just need to get this data into XML.


Called with

        i = 0
        Do While i <= arr.Length - 1
            GetSG2_Data(arr(i), i, lastrun)
            i += 1

'arr(i) is 7 in length.

Private Function Get_Data(ByVal arr As String, ByVal index As Integer, ByVal lastrun As String) As Boolean
        On Error GoTo Error_code
        Dim rpt As CRAXDRT.Report
        Dim rpt_nd As MSXML2.IXMLDOMNode
        Dim filter_nd As MSXML2.IXMLDOMNode
        Dim cr As CRAXDRT.Application
        Dim userid, pwd As Object

        'new application
        cr = New CRAXDRT.Application()
        'crystal login info
        userid = ""
        pwd = ""

        'open specified report
        rpt = cr.OpenReport("S:\c\tech\Reports\" & arr & ".rpt")
        'only log in at application level if it is the first file, else max simultaneous users error
        rpt.Database.Tables(1).ConnectBufferString = "Provider=MSDAORA;;Data Source=w514p;;User ID=" & userid & ";;Password=" & pwd & ";;Locale Identifier=1033;;OLE DB Services=-5"

        '5/6/2003 12:00:00AM ---> DateTime(Y,M,D,H,M,S)
        'sets filter to the get all updates and inrts from last run date
        'lastrun = 2004,11,01,00,00,00 in this case
        If index = 3 Or index = 0 Then
            rpt.RecordSelectionFormula = "{Command.UPDATE_DATE} >= DateTime(" & lastrun & ") OR {Command.INSERT_DATE} >= DateTime(" & lastrun & ")"
        End If
        '***end filter section

        'export xml from crystal
        rpt.ExportOptions.DestinationType = CRAXDRT.CRExportDestinationType.crEDTDiskFile
        rpt.ExportOptions.FormatType = CRAXDRT.CRExportFormatType.crEFTXML
        rpt.ExportOptions.XMLFileName = "c:\xml\" & arr & ".xml"
        rpt = Nothing
        cr = Nothing
        Exit Function
        logger.WriteLine("Get\Error @ " & Now() & ": " & Err.Number & vbTab & Err.Source & vbTab & Err.Description, EventLogEntryType.Error)
        Resume Exit_code
    End Function
Question by:cmgtech
  • 3
LVL 101

Accepted Solution

mlmcc earned 2000 total points
ID: 12712553
CR.Net is a reduced feature version of Crystal 9.  Crystal provided it to M$ as a way of tempting people to purchase the full version after getting a taste of the capability.

Crystal has done similar things with the trial versions and with some of the viewers.

LVL 101

Expert Comment

ID: 12713155
Look at the feature comparison by version. CR.Net cannot export to XML directly.


You might be able to trick it by including th CR8 XML export dll.


Author Comment

ID: 12718136
I really cannot believe that this can happen.  It is embarassing that even though I own CR 9 Developer Pro and can export using the COM object, I can't use the .NET version.  Dammit.  

Thanks guys.
LVL 101

Expert Comment

ID: 12722016
That was their intent with CR.Net.  To create a desire to get the other features.

Glad i could help


Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question