Running a Crystal Report in a VB .Net 2008 Application on Client after installation

When I try to generate the report I get the attached prompt asking me to log in but the database path and server name are pointing to where the database was located on the computer that the application was developed.

Below I have included the code where I passed the parameters.

        Dim cryRpt As New ReportDocument
        Dim crParameterFieldDefinitions As ParameterFieldDefinitions
        Dim crpfdRegNo As ParameterFieldDefinition
        Dim crpfdDate As ParameterFieldDefinition
        Dim crpvDate As New ParameterValues, crpvRegNo As New ParameterValues
        Dim crpdvDate As New ParameterDiscreteValue
        Dim crpdvRegno As New ParameterDiscreteValue

        If dgvList.Rows.Count = 0 Then Exit Sub

        Me.Cursor = Cursors.WaitCursor

        cryRpt.Load(System.AppDomain.CurrentDomain.BaseDirectory & "C3Statement.rpt")

        'Get the parameter fields from the crystal report
        crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields

        'Get specified parameter from the definition
        crpfdDate = crParameterFieldDefinitions.Item("C3Date")
        crpfdRegNo = crParameterFieldDefinitions.Item("regnum")

        ''Get the current values from the parameter field.  At this point
        ''there are zero values set.
        crpvDate = crpfdDate.CurrentValues
        crpvRegNo = crpfdRegNo.CurrentValues

        'Fill Date Parameter
        crpdvDate.Value = dgvList.CurrentRow.Cells(1).Value
        'Fill Registration Number parameter
        crpdvRegno.Value = dgvList.CurrentRow.Cells(0).Value

        frmPrint.crvViewReport.ReportSource = cryRpt

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SheldonCAuthor Commented:
Here is the image file with the login request.
If you login does the report run or does the client have a different database?

You can change the database through the application
Look starting on page 113 in this walkthrough

Éric MoreauSenior .Net ConsultantCommented:
that's in part why I prefer to pass a filled dataset to my reports. see
SheldonCAuthor Commented:
I needed to pass the connection information to the Report. I found the following functions somewhere but I can't remember where.

 Function ApplyLogon(ByVal cr As ReportDocument, ByVal ci As ConnectionInfo) As Boolean

        Dim li As TableLogOnInfo
        Dim tbl As Table

        ' for each table apply connection info  
        For Each tbl In cr.Database.Tables
            li = tbl.LogOnInfo
            li.ConnectionInfo = ci

            ' check if  logon was successful  
            ' if  TestConnectivity returns false,  
            ' check logon credentials  
            If (tbl.TestConnectivity()) Then
                'drop fully qualified table location  
                If (tbl.Location.IndexOf(".") > 0) Then
                    tbl.Location = tbl.Location.Substring(tbl.Location.LastIndexOf(".") + 1)
                    tbl.Location = tbl.Location
                End If
                Return False
            End If
            Return True
    End Function

    Function Logon(ByVal cr As ReportDocument, ByVal server As String, ByVal db As String, ByVal id As String, ByVal pass As String) As Boolean

        Dim ci As New ConnectionInfo
        Dim subObj As SubreportObject
        Dim obj As ReportObject

        ci.ServerName = server
        ci.DatabaseName = db
        ci.UserID = id
        ci.Password = pass

        If Not (ApplyLogon(cr, ci)) Then
            Return False
        End If

        For Each obj In cr.ReportDefinition.ReportObjects
            If (obj.Kind = ReportObjectKind.SubreportObject) Then
                subObj = CType(obj, SubreportObject)
                If Not (ApplyLogon(cr.OpenSubreport(subObj.SubreportName), ci)) Then
                    Return False
                End If
            End If
        Return True
    End Function


Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.