Results 1 to 3 of 3

Thread: [RESOLVED] Hating CR again...

  1. #1

    Thread Starter
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Resolved [RESOLVED] Hating CR again...

    I'm using CR11 to report off an Access DB calling from VB.Net 2005

    Here is my code:

    VB Code:
    1. Public Sub DisplayReport(ByVal mRepName As String, ByVal mstrW As String, Optional ByVal strTitle As String = "")
    2.         Dim mRep As New CrystalDecisions.CrystalReports.Engine.ReportDocument
    3.         'Dim tbCurrent As CrystalDecisions.CrystalReports.Engine.Table
    4.         Dim ConInfo As New CrystalDecisions.Shared.TableLogOnInfo
    5.         Dim paraValue As New CrystalDecisions.Shared.ParameterDiscreteValue
    6.         'Dim currValue As CrystalDecisions.Shared.ParameterValues
    7.         'Sub report object of crystal report.
    8.         Dim mySubReportObject As CrystalDecisions.CrystalReports.Engine.SubreportObject
    9.         'Sub report document of crystal report.
    10.         Dim mySubRepDoc As New CrystalDecisions.CrystalReports.Engine.ReportDocument
    11.  
    12.         Try
    13.             ' Load the report
    14.             mRep.Load(mRepName)
    15.             mRep.RecordSelectionFormula = mstrW
    16.             If strTitle <> String.Empty Then
    17.                 mRep.SummaryInfo.ReportTitle = strTitle
    18.             End If
    19.             ConInfo.ConnectionInfo.DatabaseName = mdlGeneral.gstrFullDBInfo
    20.  
    21.             For i As Integer = 0 To mRep.Database.Tables.Count() - 1
    22.                 mRep.Database.Tables(i).ApplyLogOnInfo(ConInfo)
    23.             Next i
    24.  
    25.             'Check for Subreprots
    26.             For i As Integer = 0 To mRep.ReportDefinition.Sections.Count - 1
    27.                 For x As Integer = 0 To mRep.ReportDefinition.Sections(i).ReportObjects.Count - 1
    28.                     With mRep.ReportDefinition.Sections(i)
    29.                         If .ReportObjects(x).Kind = CrystalDecisions.Shared.ReportObjectKind.SubreportObject Then
    30.                             mySubReportObject = CType(.ReportObjects(x), CrystalDecisions.CrystalReports.Engine.SubreportObject)
    31.                             mySubRepDoc = mySubReportObject.OpenSubreport (mySubReportObject.SubreportName) <--Errors Here wirh Invalide table Number
    32.                             For z As Integer = 0 To mySubRepDoc.Database.Tables.Count - 1
    33.                                 mySubRepDoc.Database.Tables(z).ApplyLogOnInfo(ConInfo)
    34.                             Next z
    35.                         End If
    36.                     End With
    37.                 Next x
    38.             Next i
    39.  
    40.             ' Set the report source for the crystal reports viewer to the report instance.
    41.             Me.crViewer.ReportSource = mRep
    42.  
    43.             ' Zoom viewer to fit to the whole page so the user can see the report
    44.             Me.crViewer.Zoom(100)
    45.             'Me.crViewer.ShowRefreshButton = False
    46.             Me.crViewer.DisplayGroupTree = False
    47.         Catch crExp As CrystalDecisions.CrystalReports.Engine.LoadSaveReportException
    48.             MessageBox.Show("Error printing Report " & mRepName & System.Environment.NewLine & _
    49.                 "The error number is: " & Err.Number.ToString() & System.Environment.NewLine & _
    50.                 "The error Message is: " & System.Environment.NewLine & crExp.Message.Trim(), "Print Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
    51.         Catch ex As Exception
    52.             MessageBox.Show("Error printing Report " & mRepName & System.Environment.NewLine & _
    53.                             "The error number is: " & Err.Number.ToString() & System.Environment.NewLine & _
    54.                             "The error Message is: " & System.Environment.NewLine & ex.Message.Trim(), "Print Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
    55.         End Try
    56.  
    57.     End Sub
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  2. #2
    Addicted Member mabbas110's Avatar
    Join Date
    Oct 2005
    Location
    Karachi , Pakistan
    Posts
    172

    Re: Hating CR again...

    Please if u can also specify the probelm u r getting in it.
    Thanks and Regards,

    Muhammad Abbas

  3. #3

    Thread Starter
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Hating CR again...

    I did the there is a line marked and the error is invalid table number.

    mySubRepDoc = mySubReportObject.OpenSubreport (mySubReportObject.SubreportName) <--Errors Here wirh Invalide table Number
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width