Link to home
Start Free TrialLog in
Avatar of John500
John500Flag for United States of America

asked on

Migrating Applications from the Crystal Report Designer Component to the .Net assemblies (VS 2005)

Greetings,

I created many reports using the RDC as an add-in to Visual Basic version 6.0.   Now I'd like to recreate those reports using the CR .Net assemblies and VB 2005.

I used the Visual Studio upgrade wizard to attempt this conversion but I'm not out of the woods yet.  Apparently the wizard can't make all the changes.  I need to get rid of everything in my code that makes use of craxdrt.dll or crviewer.dll.

These are the only errors I'm getting presently and I'm sure these errors will identify the kinds of changes I need.

Error:  Name 'CRViewer11' is not declared.
Error:  Type 'CRAXDRT.Sections' is not defined
Error:  Type 'CRAXDRT.Database' is not defined
Error:  'ReportViewer1' is not a member of 'Project1.Form2'
Error:  Type AxCrystalActiveXReportViewerLib11_5._ICRViewerEvents_PrintButtonClickedEvent is not defined
Error:  Type AxCrystalActiveXReportViewerLib11_5._ICRViewerEvents_RefreshButtonClickedEvent is not defined

I've attached the declarations of the module and the primary function of the Form along with attempted changes.

Thanks for the help!
Module
 
    Dim ConnectString, Query As String
    Public param2 As CrystalDecisions.Shared.ParameterField
    Public ADOcn1 As New ADODB.Connection
    Public ADOConnect1 As New ADODB.Recordset       // old method
    Public ADOConnect2 As DataSet = New DataSet()   // new method ??
    Public crDatabase As CRAXDRT.Database           // old method
 
Form1
 
 
 Public Sub displayReport(ByRef param As String)
 
        Dim paramDiscreteValue As New CrystalDecisions.Shared.ParameterDiscreteValue()
        Dim paramValues As New CrystalDecisions.Shared.ParameterValues
 
        
        'Call CreateRecordsets()   // not sure how to replace
 
        param2 = Form1.Report.ParameterFields(0)
        ' Clear the current value
        param2.CurrentValues.Clear()
        ' Set param 2 to a new String value
        paramDiscreteValue.Value = param
        paramValues.Add(paramDiscreteValue)
        param2.CurrentValues.Add(paramValues.Item(0))
 
        
        Form1.Report.Database.Tables.Item(1).SetDataSource(ADOConnect2)  // changes yes/no?
        Me.Show()
        Me.Enabled = True
        CRViewer11.ReportSource = Form1.Report   // error on CRViewer11
        CRViewer11.ViewReport()                  // error on CRViewer11
    End Sub

Open in new window

Avatar of Mike McCracken
Mike McCracken

I don't use .Net buit you need to add the Crystal.Net assemblies to your project.

mlmcc
Avatar of John500

ASKER

.Net assemblies were added to the project by removing the old viewer and adding in the new
Did you know that there is reporting services functionality in VB.NET 2005, that doesn't require Crystal Reports or any ActiveX components?

Applied MS Reporting Services 101 using Smart Client
http://www.codeproject.com/KB/reporting-services/rswin101.aspx

Bob
Avatar of John500

ASKER

Bob,

Nice of you to drop in.  I did noticed the MS Reporting Services.  I guess from a learning curve perspective I figured there would be less going CR.

Any thoughts?  Thanks
With that said and out of the way, are you still using ADO classic for database access?  What version is the reference for Crystal?  Does the form designer file have the reference for the CRViewer11?

Bob
Avatar of John500

ASKER

>> are you still using ADO classic for database access?

I'm in the process of trying to understand just what the impacts are of migrating to the .Net Assemblies.  I have no problem with using the CR .Net Assemblies.  

The project so far has been upgraded using the VS 2005 wizard.  From there I deleted the old viewer and replaced it with the new.  This automatically updated my references but maybe not all of them.

The project consists of two forms and a module.  The first form takes a parameter, the second form shows the viewer and the module makes a connection to an MSSQL database (2005).

I have attached four files (Form1, Form2, module & pic of my references).  If you take a look, you will probably agree I'm not far from the goal.
Form1.txt
Form2.txt
Module1.txt
references.JPG
Avatar of John500

ASKER

... Any occurrance of the variable 'ADOFail2' in the module should be ADOConnect2
If you are not talking about a complicated process, I would go through the process of learning the .NET way, and re-engineering, instead of migrating from the old process.  The new process can use either a strong-typed DataSet, or internal .NET business object classes to provide the input for the reports.

Bob
Avatar of John500

ASKER

When you look at this project do you see the conversion steps or how you would proceed starting from scratch?  If so, what are these steps?

My ideal solution here would be to receive the steps and necessary code using this project as a basis for conversion.  I can post this question a couple of times to restart the points counter if necessary.

Thanks
>>do you see the conversion steps

This is the first thing that I saw when I opened Form1.vb:

Dim par As String
par = VB6.GetItemString(List1, List1.SelectedIndex)

VB.NET:
Dim par As String = List1.SelectedItem.ToString()

Bob
Avatar of John500

ASKER

Ok, done.

I'm ready for any all changes.
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

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 John500

ASKER

Bob,

Looks like a good reference.  Thanks.

Regarding the change below:

Dim par As String
par = VB6.GetItemString(List1, List1.SelectedIndex)

VB.NET:
Dim par As String = List1.SelectedItem.ToString()

... that worked also.

I shouldn't have any more questions but let me see if I can get this thing to work.


Avatar of John500

ASKER

Thanks again