?
Solved

VB.NET, Crystal Reports.  This property is currently in a read-only state and cannot be modified.

Posted on 2004-11-29
5
Medium Priority
?
1,922 Views
Last Modified: 2007-12-19
Hello,

I am running a Crystal Reports export to XML and am running into an issue.  I am using the COM object.  I get the error:  "This property is currently in a read-only state and cannot be modified." when I run my app sometimes.  It ishard to reproduce and the only way I can tell this is set off is by certain dates in my LASTRUN variable.  Sometimes dates will work and others won't.  The confusing thing is that index 0-4 will work fine and then when it gets to 5 it will error out.  Although other times, none of them will work.  I don't know and am very confused.

Thanks,

Mark


Here is the code:
Passing:
2004,11,12,00,00,00 as lastrun
5 as index
DataDump_Property as arr

    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("c:\" & 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=_____;;User ID=" & userid & ";;Password=" & pwd & ";;Locale Identifier=1033;;OLE DB Services=-5"
        rpt.DiscardSavedData()




        '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
        If index = 3 Or index = 0 Then
        Else
            rpt.RecordSelectionFormula = "{Command.UPDATE_DATE} >= DateTime(" & lastrun & ") OR {Command.INSERT_DATE} >= DateTime(" & lastrun & ")"
        End If
        '***end filter section

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

Expert Comment

by:planocz
ID: 12705423
What ver of CR are you running?
0
 

Author Comment

by:cmgtech
ID: 12708850
CR 9.  The problem only seems to happen for certain dates but that is only a guess... pretty new to this and I have lost a lot of sleep over this without being able to find any acceptable workaround or even an explaination or reason of this error.

Here is some of my error log:

Start: 11/30/2004 2:58:20 AM
For Dates: 2004,11,29,00,00,00
DataDump_L: 11/30/2004 2:59:16 AM
DataDump_R: 11/30/2004 2:59:23 AM
Get\Error @ 11/30/2004 2:59:26 AM: -2147417851      Interop.CRAXDRT      The server threw an exception.
DataDump_L: 11/30/2004 2:59:27 AM
DataDump_Lo: 11/30/2004 2:59:34 AM
Get\Error @ 11/30/2004 2:59:35 AM: -2147184634            This property is currently in a read-only state and cannot be modified.
DataDump_Loa: 11/30/2004 2:59:37 AM
Get\Error @ 11/30/2004 2:59:40 AM: -2147184634            This property is currently in a read-only state and cannot be modified.
DataDump_Pr: 11/30/2004 2:59:41 AM
Get\Error @ 11/30/2004 2:59:42 AM: -2147184634            This property is currently in a read-only state and cannot be modified.
DataDump_Pre: 11/30/2004 2:59:42 AM
DataDump_R(merge): 11/30/2004 2:59:45 AM
DataDump_Loa (merge): 11/30/2004 2:59:54 AM
DataDump_Lo (merge): 11/30/2004 3:01:18 AM
DataDump_L (merge): 11/30/2004 3:02:20 AM
DataDump_Pr (merge): 11/30/2004 3:02:34 AM
DataDump_P (merge): 11/30/2004 3:02:39 AM
Remove Nodes: 11/30/2004 3:02:44 AM
Passing to Update Page: 11/30/2004 3:02:44 AM
File Loaded, Posted.
Done Processing @ 11/30/2004 3:04:43 AM
******************************************
0
 
LVL 27

Accepted Solution

by:
planocz earned 1500 total points
ID: 12709119
Well first of all I would not use the CRAXDRT object.
Here is some code that I use with cr9...

'CONNECTIONS

You can use a ADO or SQL connection...

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.ReportSource
Imports CrystalDecisions.Shared
Imports ADODB                                 '<---- Access
Imports System.Data.SqlClient            '<---- SQL

    Public myReport As New ReportDocument        'Gobal Report Doc
    Public sAppPath = Application.StartupPath        'Application Directory Main Path
    Public sReportPath = "\Reports\"                     'Reports Directory Path


   '**** Server Connection Vars *********
    Public sDBServer As String = "MYSERVER"
    Public sUSERid As String = "MYUSER"
    Public sDBName As String = "MYDATABASE"
    Public sDBPass As String = ""
    Public Con As OleDb.OleDbConnection      '<--- for Access
    Public Connect As SqlConnection             '<--- for msSQL
    Public sSQL As String


    Private Sub GetReportConnection(ByVal myReport)
        ' Objects used to set the proper database connection information
        Dim tbCurrent As CrystalDecisions.CrystalReports.Engine.Table
        Dim tliCurrent As CrystalDecisions.Shared.TableLogOnInfo

        Try
            ' Load the report
            myReport.Load(sAppPath & sReportPath & sReportName, CrystalDecisions.[Shared].OpenReportMethod.OpenReportByTempCopy)
            ' Set the connection information for all the tables used in the report
            For Each tbCurrent In myReport.Database.Tables
                tliCurrent = tbCurrent.LogOnInfo
                With tliCurrent.ConnectionInfo
                    .ServerName = sDBServer
                    .UserID = sUSERid
                    .Password = ""
                    .DatabaseName = sDBName
                End With
                tbCurrent.ApplyLogOnInfo(tliCurrent)
            Next tbCurrent
        Catch Exp As LoadSaveReportException
            MsgBox("Incorrect path for loading report.", _
                    MsgBoxStyle.Critical, "Load Report Error")
        Catch Exp As Exception
            MsgBox(Exp.Message & "   in GetReportConnection Procedure", MsgBoxStyle.Critical, "General Error")
        End Try
    End Sub

'PROCEDURE FOR EXPORTING

  Private Sub ExptReport(ByVal myReport)
       Dim myExportOptions As New CrystalDecisions.Shared.ExportOptions
       Dim myDiskFileDesOptions As New CrystalDecisions.Shared.DiskFileDestinationOptions

  Try
                          myDiskFileDesOptions.DiskFileName = sAppPath & sReportPath &  "MYXMLFILE.html"
                            myExportOptions = myReport.ExportOptions
                            Dim myFormatTypOpt As New CrystalDecisions.Shared.HTMLFormatOptions
                            With myFormatTypOpt
                                .HTMLBaseFolderName = sReportPath
                                .HTMLFileName = myDiskFileDesOptions.DiskFileName
                                .HTMLEnableSeparatedPages = True
                                .HTMLHasPageNavigator = True
                            End With
                            With myExportOptions
                                .ExportDestinationType = CrystalDecisions.[Shared].ExportDestinationType.DiskFile
                                .ExportFormatType = CrystalDecisions.[Shared].ExportFormatType.HTML40
                                .DestinationOptions = myDiskFileDesOptions
                                .FormatOptions = myFormatTypOpt
                            End With
                    myReport.Export()
                Catch Exp As ExportException
                    MsgBox("Incorrect path for saving report.", _
                            MsgBoxStyle.Critical, "Load Report Error")
                Catch Exp As System.Reflection.TargetInvocationException
                    'Jump over this error
                Catch Exp As Exception
                    MsgBox(Exp.Message & " in CheckReportList", MsgBoxStyle.Critical, "General Error")
                End Try
            End If
      End Sub

'SAMPLE for PASSING Parameters

  Private Sub Parmas(ByVal myReport) 'FOR Dates and Ranges
        ' Objects used to set the parameters in the report
        Dim pvCollection As New ParameterValues
        Dim pdvID As New ParameterDiscreteValue
        Dim pdvStartName As New ParameterDiscreteValue
        Dim pdvEndName As New ParameterDiscreteValue
        Dim pdvPageCount As New ParameterDiscreteValue
        Try
                '********************************* ID **********************************
                ' Set the discreet value to the Start Date.
                pdvID.Value = sdbID
                ' Add it to the parameter collection.
                pvCollection.Add(pdvID)
                ' Apply the current parameter values.
                myReport.DataDefinition.ParameterFields("ID").ApplyCurrentValues(pvCollection)

                '********************************* Start Date **********************************
                pdvStartName.Value = sDBStartDate
                pvCollection.Add(pdvStartName)
                myReport.DataDefinition.ParameterFields("Start Date").ApplyCurrentValues(pvCollection)

                '********************************* End Date **********************************
                pdvEndName.Value = sDBEndDate
                pvCollection.Add(pdvEndName)
                myReport.DataDefinition.ParameterFields("End Date").ApplyCurrentValues(pvCollection)
 
                '********************************* Page Count **********************************
                pdvPageCount.Value = iPageCount + 1
                pvCollection.Add(pdvPageCount)
                myReport.DataDefinition.ParameterFields("Page Count").ApplyCurrentValues(pvCollection)
         Catch Exp As ParameterFieldException
            MsgBox("Incorrect Parameter Field." & vbNewLine & "In Parmas Procedure Code", _
                    MsgBoxStyle.Critical, "Load Report Error")
        Catch Exp As InvalidArgumentException
            MsgBox(Exp.Message & vbNewLine & "In Parmas Procedure Code", MsgBoxStyle.Critical, "General Error")
        Catch Exp As Exception
            MsgBox(Exp.Message & vbNewLine & "In Parmas Procedure Code", MsgBoxStyle.Critical, "General Error")
        End Try
    End Sub

'This may not what you are looking for, but I think the  new .NET code will help you.
Then using Interop. object.
0
 

Author Comment

by:cmgtech
ID: 12709206
Thanks, I'll try it out later today and get back to you hopefully by tomorrow... a little busy lately.

Regards,


Mark
0
 

Author Comment

by:cmgtech
ID: 12710647
tried it out and i connect and can export to pdf fine with no errors.  the thing is, I dont know when this is going to crash out.  also I now have to export it to XML and con't find anything about how to do it anywhere.  with the CRAXDRT, I can just change portabledocumentformat to xml and it is fine.  no idea how to do it here and really con't find anyhting on how to do it.  

Thanks a lot, you really got me at least on the right track.


I am going to start a new thread that may help people find it easier.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses
Course of the Month16 days, 7 hours left to enroll

850 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