Quantcast
Channel: SCN : Discussion List - SAP Crystal Reports, version for Visual Studio
Viewing all articles
Browse latest Browse all 3636

Print, ask for parameters, set table locations, but can't display report?

$
0
0

Dang, I'm sooooooooooooo close!  The attached VB code reads a file, modifies formulas, redirects tables to new ones, will evern PRINT the danged reports, but will NOT SHOW them?  I'm converting from an old VS2008 version, where all that was needed was a CrystalReportViewer2.Refresh().

 

It absolutely connects to the database - I've printed out numerous reports, but it will NOT display them.

 

What am I missing?

 

Private Sub ShowReport()

      Dim errstr As String = "No Error"

      Try

        Dim crtableLogoninfos As New CrystalDecisions.Shared.TableLogOnInfos()

        Dim crtableLogoninfo As New CrystalDecisions.Shared.TableLogOnInfo()

        'Dim crConnectionInfo As New CrystalDecisions.Shared.ConnectionInfo()

        Dim CrTables As CrystalDecisions.CrystalReports.Engine.Tables

        Dim CrTable As CrystalDecisions.CrystalReports.Engine.Table

        Dim i As Integer

 

        errstr = "Loading Report"

        crReportDocument.Load(ReportName)

 

        'This code works for both user tables and stored

        'procedures. Set the CrTables to the Tables collection

        'of the report

 

            CrTables = crReportDocument.Database.Tables

            crReportDocument.SetDatabaseLogon("RPT", MyPassWord)

 

 

        'change formula values

        i = 1

        While (i < MaxParms) And (Parms(i, 1) <> "")

          errstr = "Setting Formula " & Parms(i, 1)

          crReportDocument.DataDefinition.FormulaFields(Parms(i, 1)).Text = Parms(i, 2)

          i = i + 1

        End While

 

        ' now add login info to each table, see if needs to be changed

        i = 1

        For Each CrTable In CrTables

          crtableLogoninfo = CrTable.LogOnInfo

                'crtableLogoninfo.ConnectionInfo.ServerName = "IQORA"

                crtableLogoninfo.ConnectionInfo.UserID = "RPT"

                crtableLogoninfo.ConnectionInfo.Password = MyPassWord

                CrTable.ApplyLogOnInfo(crtableLogoninfo)

                MessageBox.Show(CrTable.Name & " - " & CrTable.Location & " - " & TableNames(i, 1))

          If (i < MaxTables) Then

            If (TableNames(i, 1) <> Nothing) Then

              errstr = "Setting table " & CrTable.Location & " to " & TableNames(i, 1)

              CrTable.Location = TableNames(i, 1)

            End If

          End If

                'MessageBox.Show(CrTable.Name & " - " & CrTable.Location)

                i = i + 1

            Next

 

            errstr = "Display"

            'Set the viewer to the report object to be previewed.

 

            'MessageBox.Show(crReportDocument.FileName)

            CrystalReportViewer2.ReportSource = crReportDocument '"R:\Rpt60\IMC_Templatex.rpt"

            'CrystalReportViewer2.PrintReport()

            CrystalReportViewer2.Refresh()

            CrystalReportViewer2.RefreshReport()

 

 

        Catch E As Exception

            ' Let the user know what went wrong.

            MessageBox.Show("Report error:  " & errstr & E.Message)

        End Try

    End Sub

 

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

      Readparms()

      ShowReport()

    End Sub


Viewing all articles
Browse latest Browse all 3636

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>