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

Posted on 2004-11-30
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
    LVL 100

    Accepted Solution

    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 100

    Expert Comment

    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

    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 100

    Expert Comment

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

    Glad i could help


    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
    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 …
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    745 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now