Solved

Upgrade from Crystal Report 8 to Crystal Report 2008

Posted on 2011-09-29
24
1,298 Views
Last Modified: 2012-06-21
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.
0
Comment
Question by:sivaman
  • 15
  • 9
24 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 36818267
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
0
 

Author Comment

by:sivaman
ID: 36909956
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.
0
 

Author Comment

by:sivaman
ID: 36912660
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
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 100

Expert Comment

by:mlmcc
ID: 36913177
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
0
 

Author Comment

by:sivaman
ID: 36913209
Im using Crystal Reports 2008. How can we add the picture from a file path using crystal reports 2008?
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 36913269
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
0
 

Author Comment

by:sivaman
ID: 36913370
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.
0
 

Author Comment

by:sivaman
ID: 36913486
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
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 36913545
WHere is the file path stored?

Can you build a formula like

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

mlmcc
0
 

Author Comment

by:sivaman
ID: 36917622
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
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 36917941
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
0
 

Author Comment

by:sivaman
ID: 36918062
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..
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 36918170
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
0
 

Author Comment

by:sivaman
ID: 36918334
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
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 36918504
Is the parameter named imglocation?

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

mlmcc
0
 

Author Comment

by:sivaman
ID: 36918538
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..
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 36918823
Is it working?

mlmcc
0
 

Author Comment

by:sivaman
ID: 36920551
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

0
 

Author Comment

by:sivaman
ID: 36920671
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
0
 

Author Comment

by:sivaman
ID: 36920812
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

0
 

Author Comment

by:sivaman
ID: 36921268
Dear mlcc,

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

Author Comment

by:sivaman
ID: 36927415
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..
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 36928006
I have never written any code to try to access report objects.

You might write a short app that opens the report and uses a loop like
  For Each crSection IN ReportSections
     Display the section name

Same way for other objects on the report or in a section

mlmcc
0
 

Author Closing Comment

by:sivaman
ID: 36944765
Thanks a lot mlmcc
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
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 Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

735 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