Results 1 to 4 of 4

Thread: [RESOLVED] CR 10.2 - Keep getting Database Login screen for SubReport?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Resolved [RESOLVED] CR 10.2 - Keep getting Database Login screen for SubReport?

    I've created a sub-report within my Crystal Report. I'm using the same DB tables as I do in the main report but now I get the Database Login prompt. What's causing that?

    Thanks,
    Blake

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: CR 10.2 - Keep getting Database Login screen for SubReport?

    anyone got any ideas?
    Blake

  3. #3
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: CR 10.2 - Keep getting Database Login screen for SubReport?

    This is how I call to CR (on the form with the CR Viewer)

    vb Code:
    1. Public Sub DisplayReport(ByVal mRepName As String, ByVal mstrW As String, Optional ByVal strPars As String = "")
    2.         Dim mRep As New CrystalDecisions.CrystalReports.Engine.ReportDocument
    3.         Dim ConInfo As New CrystalDecisions.Shared.TableLogOnInfo
    4.         Dim paraValue As New CrystalDecisions.Shared.ParameterDiscreteValue
    5.         Dim currValue As New CrystalDecisions.Shared.ParameterValues
    6.         Dim mySubReportObject As CrystalDecisions.CrystalReports.Engine.SubreportObject
    7.         Dim mySubRepDoc As New CrystalDecisions.CrystalReports.Engine.ReportDocument
    8.         Dim i, x, z As Integer 'Some Counters
    9.  
    10.         Try
    11.             ' Load the report
    12.             'Need to add the report dll yet Nothing Works
    13.             Dim rep As New RSMReports.clsReports(mRepName)
    14.             mRep = rep.returnRep()
    15.             mRep.RecordSelectionFormula = mstrW
    16.  
    17.  
    18.             'SQL Server
    19.             ConInfo.ConnectionInfo.UserID = Your user ID Here            ConInfo.ConnectionInfo.Password = Your Password Here
    20.             ConInfo.ConnectionInfo.DatabaseName = Database Here
    21.             For i = 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 = 0 To mRep.ReportDefinition.Sections.Count - 1
    27.                 For x = 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)
    32.                             For z = 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.             If strPars.Trim() <> String.Empty Then
    43.                 Dim arPars As String() = strPars.Split("~")
    44.                 Dim strVal As String()
    45.                 For xx As Integer = 0 To arPars.GetUpperBound(0)
    46.                     strVal = arPars(xx).Split("=")
    47.                     paraValue.Value = strVal(1)
    48.                     currValue = mRep.DataDefinition.ParameterFields(strVal(0)).CurrentValues
    49.                     currValue.Add(paraValue)
    50.                     mRep.DataDefinition.ParameterFields(xx).ApplyCurrentValues(currValue)
    51.                 Next
    52.             End If
    53.             ' Zoom viewer to fit to the whole page so the user can see the report
    54.             Me.crViewer.Zoom(100)
    55.             'Me.crViewer.ShowRefreshButton = False
    56.             Me.crViewer.DisplayGroupTree = False
    57.         Catch crExp As CrystalDecisions.CrystalReports.Engine.LoadSaveReportException
    58.             MessageBox.Show("Error printing Report " & mRepName & System.Environment.NewLine & _
    59.                 "The error number is: " & Err.Number.ToString() & System.Environment.NewLine & _
    60.                 "The error Message is: " & System.Environment.NewLine & crExp.Message.Trim(), "Print Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
    61.         Catch ex As Exception
    62.             MessageBox.Show("Error printing Report " & mRepName & System.Environment.NewLine & _
    63.                             "The error number is: " & Err.Number.ToString() & System.Environment.NewLine & _
    64.                             "The error Message is: " & System.Environment.NewLine & ex.Message.Trim(), "Print Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
    65.         End Try
    66.  
    67.     End Sub
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: CR 10.2 - Keep getting Database Login screen for SubReport?

    Thanks Gary,

    I'll pick and choose from the code and see what happens.
    Blake

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