Solved

Upgrade from Crystal Report 8 to Crystal Report 2008

Posted on 2011-09-29
24
1,282 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
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
Comment Utility
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
Comment Utility
Is the parameter named imglocation?

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

mlmcc
0
 

Author Comment

by:sivaman
Comment Utility
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
Comment Utility
Is it working?

mlmcc
0
 

Author Comment

by:sivaman
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Dear mlcc,

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

Author Comment

by:sivaman
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks a lot mlmcc
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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. …
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 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

15 Experts available now in Live!

Get 1:1 Help Now