Avatar of Larry Rungren
Larry RungrenFlag for United States of America

asked on 

assistance converting crystalreports 2011 reports

i am desperate to find someone who can explain how to uses existing reports (all called from vb6 with ease) to be called from vb.net

I have asked several questions ans so far none of the answers have worked.  i seem to get the feeling that these reports will have to be called in a totally different method, most answers seem to advocate using .xsd files with a push method.

1. Does this mean all reports have to be re-written, or can a datasource change handle the issue.

2. Reports will run as they exist, but there doesn't seem to be a way to pass sql login info. All reports require user to login to the database.

I have read so much online but 95% is how to create reports, and very little on using existing reports.

Is there anyone that can help me with this,  8-10 lines of code in VB6 seems to be 60 plus in VB.NET.
Crystal ReportsVisual Basic.NET.NET Programming

Avatar of undefined
Last Comment
Éric Moreau
Avatar of Larry Rungren
Larry Rungren
Flag of United States of America image

ASKER

i ask this because i want, if at all possible the leave the reports outside the .NET environment so that changes to reports, happens with great frequency, will not require a redistribution/update of the entire application to multiple users.
Avatar of Ido Millet
Ido Millet
Flag of United States of America image

Not enough information to address your question (for example, what data source and what connectivity method).

Instead of coding this yourself, there are several 3rd-party free or inexpensive Crystal Reports viewers (see list at http://kenhamady.com/bookmarks.html). Some of those viewers provide a command line API so you can call them from within your application specifying the rpt and, if necessary, parameters, login info, data source (if you need to switch data source on the fly)...
Avatar of Larry Rungren
Larry Rungren
Flag of United States of America image

ASKER

It seems that the "free" viewers are not free, like all such lists they are misleading, and when you are going to install an application on 8 - 15 desktops it gets real expensive real fast. How does an app as integrated as Crystal Reports get thrown to the wayside by MSFT, or at least put in a posture that users have to totally re-think and redesign and probably re-implement at their cost, years and years of development/
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

>>How does an app as integrated as Crystal Reports get thrown to the wayside by MSFT

Crystal is not owned by Microsoft. It has been provided for free for a long time in the box and is still available for free from the SAP website.

Your main problem is that the version you currently have working with VB6 is dated from the late 1990s. Things has since changed! VB6 moved to the .Net world so the CR also required some changes.
Avatar of Larry Rungren
Larry Rungren
Flag of United States of America image

ASKER

Eric,

You are really the only one at EE who has seemed to understand my questions.  

If I have an existing report designed and built in CR 2011, that allows the user to enter selection parameters, is there any way to run the report as-is from VB.NET?  I can load the report, enter the parameters and the report runs perfectly, with one exception,
it does not recognize the database login as passed.

Here is the code from 6-7 sites that say this should work, any idea why it doesn't?

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports CrystalDecisions.Windows.Forms
Imports CrystalDecisions.ReportSource
Public Class frmreports

    Private Sub CrystalReportViewer1_Load(sender As System.Object, e As System.EventArgs) Handles CrystalReportViewer1.Load
        dispreport()
    End Sub


    Public Sub dispreport()
        Dim cryRpt As New ReportDocument
        Dim crtableLogoninfos As New TableLogOnInfos
        Dim crtableLogoninfo As New TableLogOnInfo
        Dim crConnectionInfo As New ConnectionInfo
        Dim CrTables As Tables
        Dim CrTable As Table

        cryRpt.Load("j:\crystalreports\evaluations\completedseminaranalysis.rpt")

        With crConnectionInfo
            .ServerName = "MCLE_SQL2008\MCLE_SQL2008;"
            .DatabaseName = "iMIS_MCLE_Prod"
            .UserID = "sa"
            .Password = "password"
        End With

        CrTables = cryRpt.Database.Tables
        For Each CrTable In CrTables
            crtableLogoninfo = CrTable.LogOnInfo
            crtableLogoninfo.ConnectionInfo = crConnectionInfo
            CrTable.ApplyLogOnInfo(crtableLogoninfo)
        Next
'
'  This is from the suggested code doesn't work at all
'
        'CrystalReportViewer1.ReportSource = cryrpt

'
' Using this the report requests a database password and then runs correctly
'
        CrystalReportViewer1.ReportSource = ("j:\crystalreports\evaluations\completedseminaranalysis.rpt")               
        'CrystalReportViewer1.Show()
        CrystalReportViewer1.Refresh()
    End Sub

  
End Class

Open in new window



If this will never work, even though several people seem to think it does, can I engage your services to go through the process as you have described using the push method with .XSD files, if it does not require totally re-writing the reports?
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

>>it does not recognize the database login as passed

I would need to dig to find the issue. Your CR2011 files would also be required as I don't have that version.

>>can I engage your services to go through the process

yes as it has already been discussed.

>>as you have described using the push method with .XSD files, if it does not require totally re-writing the reports?

Changing the method to push .XSD to reports requires complete recreation of reports as you change the whole data source.
Avatar of Mike McCracken
Mike McCracken

I can't remember if I have included these links for converting VB6 to .Net

Migrating from the RDC to the .Net  Assemblies
http://scn.sap.com/docs/DOC-21971

https://msdn.microsoft.com/en-us/library/ms225492(v=vs.80).aspx

mlmcc
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

mlmcc, if Jeff is already using CR2011 as stated in his last comment, is he still using .rdc files?
You may be able to create the new connection then use the set data source to change the source.

mlmcc
I doubt it.  He was trying to convert the code from the VB6 application.  The links provide clues on how to change the VB6/RDC code to VB.Net/assemblies.  He may have mixed methods some way.

When I had to develop a report viewer for our VB6 app, we were able to make our dev network look like the prod network and had the database server names the same and on the same drives.  We were able to take the app and reports from dev to prod and everything worked with no changes.

When people ask (before developing the reports) I recommend your method.  It avoids all the issues of changing the database connection in the reports.

mlmcc
Avatar of Larry Rungren
Larry Rungren
Flag of United States of America image

ASKER

After 2 weeks of searching and trying different solutions I have found the answers I was looking for.

To run an existing Crystal report from VS2010 (VB code) that requires the user to enter a parameter value:

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports CrystalDecisions.Windows.Forms
Imports CrystalDecisions.ReportSource

Public Class frmcompletedseminar
    Private Sub CrystalReportViewer1_Load(sender As System.Object, e As System.EventArgs) Handles CrystalReportViewer1.Load
        dispreport()
    End Sub


    Public Sub dispreport()
        Dim cryRpt As New ReportDocument
        cryRpt.Load("j:\crystalreports\evaluations\completedseminaranalysis.rpt")
        cryRpt.SetDatabaseLogon("sa", "password",
                           "dsn", "databasename", False)
        CrystalReportViewer1.ReportSource = cryRpt
        CrystalReportViewer1.Show()
    End Sub

Open in new window



If, as in the case of datasource is a storedprocedure requiring parameter(s)

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports CrystalDecisions.Windows.Forms
Imports CrystalDecisions.ReportSource
Public Class frmGroupHistory

    Private Sub frmGroupCrystalReportViewer1_Load(sender As System.Object, e As System.EventArgs) Handles CrystalReportViewer1.Load
        dispreport()
    End Sub

    Public Sub dispreport()
        Dim cryRpt As New ReportDocument
        Dim paramFields As New CrystalDecisions.Shared.ParameterFields()
        Dim paramField As New CrystalDecisions.Shared.ParameterField()
        Dim discreteVal As New CrystalDecisions.Shared.ParameterDiscreteValue()
        cryRpt.Load("j:\crystalreports\evaluations\historyrecap.rpt")
        cryRpt.SetDatabaseLogon("username", "password",
                   "dsn", "database name", False)
        paramField.ParameterFieldName = "productcode"
        Dim str As String = frmControl.txtProductCode.Text.ToString
        discreteVal.Value = str
        paramField.CurrentValues.Add(discreteVal)
        paramFields.Add(paramField)
        CrystalReportViewer1.ParameterFieldInfo = paramFields
        CrystalReportViewer1.ReportSource = cryRpt
        CrystalReportViewer1.Refresh()
    End Sub
End Class

Open in new window


I have tested the app, run a build and created an install .msi and installed on another system and it works fine.

The only thing I have found is crCR for VS2010 must be installed on the client machine first.

Let me know if you see any pitfalls, PLEASE.
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Larry Rungren
Larry Rungren
Flag of United States of America image

ASKER

Along road there  but a solution to running reports  developed outside of vs2010 in Crystal reports is found.

Your support in my quest has been greatly appreciated.

The last plug I need to get working is passing the parameter to subreports, but that should be fairly straight forward now that I have the bulk of the process cut down to sensible size.

Once again THANKS
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

passing parameters to sub-reports is another interesting challenge!

the best way is to create a parameter on the main report and link the sub-report parameter to the main one (in Crystal).

I don't remember the exact steps but I found this (http://www.crystalreportsbook.com/Forum/forum_posts.asp?TID=2497) :
Follow these steps to pass the parameters from main report to sub report

1. Create a new paramter @mainParam in the main report by right-clicking on 'Parameter Fields' section in Field explorer in the main report.

2. Create a new parameter @subParam in the sub report in the same manner (This wouldn't be required if  you already have the parameter in the sub report)

3. Right click on the sub report in the desing window in your main report.

You will be able to see an option 'Change Subreport Links'.

4. Click on the option and select the @mainParam and transfer it to the sub report using '>' button.

5. Select the appropriate field in the sub report to map to

6. Click ok.

 

Now the field will be appearing only once in the criteria
.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo