Link to home
Start Free TrialLog in
Avatar of sivaman
sivamanFlag for United States of America

asked on

Upgrade from Crystal Report 8 to Crystal Report 2008

We are trying to upgrade an windows Service written in VS 2003 and Crystal Reports 8 to VS 2010 and Crystal Reports 2008. VS 2003 references "CRAXDRT.dll". I was successfully able to convert the solution to VS2010. After running the Windows Service and trying to print the report, the code blows up at the following line.

mobjInserts(intI) = New Report

and gives an error message

"Retrieving the COM class factory for component with CLSID {B4741FD0-45A6-11D1-ABEC-00A0C9274B91} failed due to the following error: 80040154.

 The Report is a public class which has CRAXDRT.Application and CRAXDRT.Report. Below is the code snippet.

Public Class Report
    Implements IDisposable

    Private mApp As New CRAXDRT.Application
    <CLSCompliant(False)> _
     Public mReport As CRAXDRT.Report
    Private mstrDefaultQueue As String
    Private mReportType As rptReportType
    Private mstrCompDisclaimers() As String
    Private mstrCompDisclaimersGroup2() As String
    Private mstrTrayDisclaimers(,) As String
    Private mstrBoldTrayDisclaimers(,) As String
    Private strClassMethodError As String
    Dim disposed As Boolean

I would like to view the reports in Crystal Reports 2008 launched from VS 2010. Please let me a solution to handle this.
Avatar of Mike McCracken
Mike McCracken

CR2008 doesn't support or include CRAXDRT.  You will need to convert to the .Net methods

This paper should help
Migrating Applications From the RDC to the Crystal Reports XI .NET Assemblies
http://www.sdn.sap.com/irj/boc/index?rid=/library/uuid/e0eb394f-931e-2b10-3b82-9413bfc3f457

mlmcc
Avatar of sivaman

ASKER

The above comment was useful. I'm in the process of following up the document and converting the code..I will let you know if I come across any hassle. Once again thanks for the comment.
Avatar of sivaman

ASKER

Hi mlmcc,
Im trying to find a replacement for AddPictureObject which is used in RDC to Crystal Reports.
mReport is the CRAXDRT.Report object.
mReport.Sections(ReportSection).AddPictureObject(strImagePath, XCoordinate, YCoordinate)
Could you please give me an replacement for AddPictureObject ?

Thanks
Siva Manickam
CR XI doesn't support that.

You can use the filepath in the OLE Object rather than adding a picture.

I don't know what the replacement would be but look at the OLE object properties.

mlmcc
Avatar of sivaman

ASKER

Im using Crystal Reports 2008. How can we add the picture from a file path using crystal reports 2008?
CR XI directions
(CR2008 should be similar)

Insert a picture into the report
Pick any picture
Right click it
Click FORMAT GRAPHIC
Click the HYPERLINK Tab
Click A FILE
Browse to the picture you want.
  You can use the formula button to choose different files based on the record

You can also store the filepath in the database and use it directly on the report

mlmcc
Avatar of sivaman

ASKER

Thanks mlmcc. But I need to dynamically load the picture from a Image path. The Image path  and co-ordiantes are given at run time . I need to add the picture programmatically using VB.net vs 2010.
Avatar of sivaman

ASKER

Dear mlmcc,

To be more precise, I need to create a place holder in crystal reports which can dynamically load images from a file path based on a specific conditions..I would appreciate if you can guide me in the right direction..

Thanks
Siva Manickam
WHere is the file path stored?

Can you build a formula like

If {CompanyName} = "AAA" then
    "c:\Pictures\AAALogo.jpg"
Else etc

mlmcc
Avatar of sivaman

ASKER

The image path is passed from the .net code..Im new to crystal reports 2008. I
I have added an jpg image, right click, format graphic --> picture tab --> Graphic Location --> added a formula "imglocation".

Now I need to access to variable imglocation from .net, and set the image path. So every time I set a new image path, the picture changes dynamically. In my case all pictures are stored in a network drive, say ex \\is11740\outbound\VectorImagesBard.

Since, Im new to crystal reports, I would appreciate if you can guide me on how to access the variable and send the image path.\
Thanks
Siva
What is the formula imglocation?

You can pass the image path as a parameter to the report.
See this code

http://www.thescarms.com/dotnet/CrystalParms.aspx

mlmcc
Avatar of sivaman

ASKER

In graphic image location , i have added a variable "imglocation". Please see attached the screen shot of what Im doing.. Crystal-Reports-2008.docx .

Please let me know if Im proceeding in the right direction..
How are you passing the value into the report?
The report doesn't know about VB variables.

Add a parameter to the report
Change your code to {?YourParameter}

mlmcc
Avatar of sivaman

ASKER

Im new to Crystal Reports..Im currently using your program to see if I can dynamically change images..Please find attached the sample code..Im also facing another problem..Im using VS 2010 and crystal reports 2008.  Im getting the below warning too..

The referenced assembly "CrystalDecisions.CrystalReports.Engine, Version=12.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, processorArchitecture=MSIL" could not be resolved because it has a dependency on "System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project.

I followed the link which you gave me..
http://www.sdn.sap.com/irj/boc/index?rid=/library/uuid/e0eb394f-931e-2b10-3b82-9413bfc3f457

Now Im trying a sample application for loading the images dynamically..I have attached the code snippet..Im getting errors like " Type ReportDocument is not defined".

should I have to change the target framework to Version 2.0?
Thanks
Siva

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ' Load the selected report file.
        '
        Dim CR As ReportDocument
        CR.Load("C:\Import Print\ImportPrint\bin\Templates\Bard\TestReport.rpt")
        '
        ' Declare the parameter related objects.
        '
        Dim crParameterDiscreteValue As ParameterDiscreteValue
        Dim crParameterFieldDefinitions As ParameterFieldDefinitions
        Dim crParameterFieldLocation As ParameterFieldDefinition
        Dim crParameterValues As ParameterValues
        Dim CrystalReportViewer As CrystalDecisions.Windows.Forms.CrystalReportViewer
        '
        ' Get the report's parameters collection.
        '
        crParameterFieldDefinitions = CR.DataDefinition.ParameterFields
        '
        ' Set the first parameter
        ' - Get the parameter, tell it to use the current values vs default value.
        ' - Tell it the parameter contains 1 discrete value vs multiple values.
        ' - Set the parameter's value.
        ' - Add it and apply it.
        ' - Repeat these statements for each parameter.
        '
        crParameterFieldLocation = crParameterFieldDefinitions.Item("imglocation")
        crParameterValues = crParameterFieldLocation.CurrentValues
        crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
        crParameterDiscreteValue.Value = "\\is11740\outbound\Test\Final JPG\logo\small\\\is11740\outbound\Test\Final JPG\logo\small\per-q-cath-midline.jpg"
        crParameterValues.Add(crParameterDiscreteValue)
        crParameterFieldLocation.ApplyCurrentValues(crParameterValues)
        '
        ' Set the Crytal Report Viewer control's source to the report document.
        '
        CrystalReportViewer.ReportSource = CR


    End Sub
End Class

Open in new window

Build-Error.docx
Is the parameter named imglocation?

If so then use this for the formula
{?imglocation}

mlmcc
Avatar of sivaman

ASKER

Dear mlcc,

Please ignore the previous comment, when I removed the
<TargetFrameworkProfile>Client</TargetFrameworkProfile> from project file the error disapppeared..

You are right..Im trying to add a parameter in report and trying to pass the value to the report..
Is it working?

mlmcc
Avatar of sivaman

ASKER

Im almost there..Im trying to View the report  but the report is not showing when I use CrystalReportViewer.ReportSource.

Please find the code below..Am I missing something??
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ' Load the selected report file.
        '
        Dim CR As New ReportDocument
        CR.Load("C:\Import Print\ImportPrint\bin\Templates\Bard\TestReport.rpt")
        '
        ' Declare the parameter related objects.
        '
        Dim crParameterDiscreteValue As ParameterDiscreteValue
        Dim crParameterFieldDefinitions As ParameterFieldDefinitions
        Dim crParameterFieldLocation As ParameterFieldDefinition
        Dim crParameterValues As ParameterValues
        Dim CrystalReportViewer As New CrystalDecisions.Windows.Forms.CrystalReportViewer

        '
        ' Get the report's parameters collection.
        '
        crParameterFieldDefinitions = CR.DataDefinition.ParameterFields
        '
        ' Set the first parameter
        ' - Get the parameter, tell it to use the current values vs default value.
        ' - Tell it the parameter contains 1 discrete value vs multiple values.
        ' - Set the parameter's value.
        ' - Add it and apply it.
        ' - Repeat these statements for each parameter.
        '

        crParameterFieldLocation = crParameterFieldDefinitions.Item("imgLocation")
        crParameterValues = crParameterFieldLocation.CurrentValues
        crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
        crParameterDiscreteValue.Value = "\\is11740\outbound\Test\Final JPG\logo\small\\\is11740\outbound\Test\Final JPG\logo\small\per-q-cath-midline.jpg"
        crParameterValues.Add(crParameterDiscreteValue)
        crParameterFieldLocation.ApplyCurrentValues(crParameterValues)
        '
        ' Set the Crytal Report Viewer control's source to the report document.
        '
        CrystalReportViewer.ReportSource = CR
        CrystalReportViewer.Show()
        'AxCrystalActiveXReportViewer1.ReportSource = CR
        'AxCrystalActiveXReportViewer1.Show()


    End Sub
End Class

Open in new window

Avatar of sivaman

ASKER

I also tried adding Crystal ActiveX Report Viewer Control 12 to the form and tried to bind the report source , it still dint work either..
It throwed me an error message attached in the screen shot.. crystal-Report-Viewer-Error.docx
Avatar of sivaman

ASKER

Dear mlcc,

Im able to view the reports in Crystal Report Viewer, but the image file is not changing , though I pass in the parameter value with a different path..Please find the code attached..

Below is the line where Im changing the image file path.
 crParameterDiscreteValue.Value = "\\is11740\outbound\Test\Final JPG\logo\small\\\is11740\outbound\Test\Final JPG\logo\small\power-picc-sv.jpg"

Am I missing something here,.
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ' Load the selected report file.
        '
        Dim CR As New ReportDocument
        CR.Load("C:\Import Print\ImportPrint\bin\Templates\Bard\TestReport.rpt")
        '
        ' Declare the parameter related objects.
        '
        Dim crParameterDiscreteValue As ParameterDiscreteValue
        Dim crParameterFieldDefinitions As ParameterFieldDefinitions
        Dim crParameterFieldLocation As ParameterFieldDefinition
        Dim crParameterValues As ParameterValues
        'Dim CrystalReportViewer As New CrystalDecisions.Windows.Forms.CrystalReportViewer

        '
        ' Get the report's parameters collection.
        '
        crParameterFieldDefinitions = CR.DataDefinition.ParameterFields
        '
        ' Set the first parameter
        ' - Get the parameter, tell it to use the current values vs default value.
        ' - Tell it the parameter contains 1 discrete value vs multiple values.
        ' - Set the parameter's value.
        ' - Add it and apply it.
        ' - Repeat these statements for each parameter.
        '

        crParameterFieldLocation = crParameterFieldDefinitions.Item("imgLocation")
        crParameterValues = crParameterFieldLocation.CurrentValues
        crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
        crParameterDiscreteValue.Value = "\\is11740\outbound\Test\Final JPG\logo\small\\\is11740\outbound\Test\Final JPG\logo\small\power-picc-sv.jpg"
        crParameterValues.Add(crParameterDiscreteValue)
        crParameterFieldLocation.ApplyCurrentValues(crParameterValues)
        '
        ' Set the Crytal Report Viewer control's source to the report document.
        '
        'CrystalReportViewer.ReportSource = CR
        'CrystalReportViewer.Show()
        CrystalReportViewer1.ReportSource = CR
        CrystalReportViewer1.Show()


    End Sub

    
End Class

Open in new window

Avatar of sivaman

ASKER

Dear mlcc,

I got this working..now im dynamically changing the text object.. Thanks for your help..
Avatar of sivaman

ASKER

Dear mlmcc,
Im trying to convert vs2003 to vs2010 and crystal reports 4.0 to crystal reports 2008. The older code had the line
mReport.Sections("Header1").ReportObjects("RUNWITHOUT").SetText(strRunWithoutText)
and I converted this line of code to
Dim RUNWITHOUT As CrystalDecisions.CrystalReports.Engine.TextObject
RUNWITHOUT = Report.ReportDefinition.Sections("Header1").ReportObjects("RUNWITHOUT")            RUNWITHOUT.Text = strRunWithoutText

Im getting an error "Value does not fall within the expected range " in the line RUNWITHOUT = Report.ReportDefinition.Sections("Header1").ReportObjects("RUNWITHOUT")           .
I'm thinking its not able to find "Header1" section in the report..was wondering if there is an way to find this out..
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sivaman

ASKER

Thanks a lot mlmcc