Paging through Crystal Report gives 'Logon Failed'. Why?

Posted on 2005-04-18
Last Modified: 2008-03-10
I have produced a application that uses the bundled Crystal Reports.
My data comes from a dataset, which is pulled out of an SQL database.
I'm using datasets as the product will be distributed to many sites.
So after much trial and error I have used ADO.Net datasets for the reports database, which just defines my fields via XML.
The report is displayed nicely in the viewer, regardless of the server being used, until I go and try and page through the report or print it.
I get the 'logon failed' popup. Why? If the data is coming out of a dataset, why do I have to logon to anything specifically for the report.
I have gone down the track of trying to pass logoninfo, but then I get the database logon dialog popup before the report starts (which is empty).

I use these statements (which seem fine)

                rptInd.Load(Application.StartupPath & "\rptDetails.rpt")

Tried both of these...same results

set the viewer source with.
           crvReport.ReportSource = rptInd

Can some one tell me where I go from here. From what i have read the error is deceptive.

I just want to say, I though the reports in VB6 were a headache, but CR ups that to migraine.
Question by:Milkus1
    LVL 27

    Expert Comment


     Imports System.IO
    Imports CrystalDecisions.CrystalReports.Engine
    Imports CrystalDecisions.ReportSource
    Imports CrystalDecisions.Shared

        Public myReport As New ReportDocument        'Gobal Report Doc

       Private Sub GetReportConnection(ByVal myReport)
            ' Objects used to set the proper database connection information
            Dim tbCurrent As CrystalDecisions.CrystalReports.Engine.Table
            Dim tliCurrent As CrystalDecisions.Shared.TableLogOnInfo

                ' Load the report
                myReport.Load(sAppPath & sReportPath & sReportName, CrystalDecisions.[Shared].OpenReportMethod.OpenReportByTempCopy)
                ' Set the connection information for all the tables used in the report
                For Each tbCurrent In myReport.Database.Tables
                    tliCurrent = tbCurrent.LogOnInfo
                    With tliCurrent.ConnectionInfo
                        .ServerName = sDBServer
                        .UserID = sUSERid
                        .Password = ""
                        .DatabaseName = sDBName
                    End With
                Next tbCurrent
            Catch Exp As LoadSaveReportException
                MsgBox("Incorrect path for loading report.", _
                        MsgBoxStyle.Critical, "Load Report Error")
            Catch Exp As Exception
                MsgBox(Exp.Message & "   in GetReportConnection Procedure", MsgBoxStyle.Critical, "General Error")
            End Try
        End Sub

    Author Comment

    Thanks...I have seen this code before and tried it to no avail.
    All this does is changes the popup to the 'database' login dialog rather then just the 'logon failed'
    If the report is only one page then everything is great.
    Soon as it generates a 2 page or more report, the problem occurs.

    I've upped the points as I need an answer quickly.


    Author Comment

    I found the answer!
    I was disposing of the report too early.
    Therefore it displayed the first page but when it went to requery it for the other pages i had disposed of it.
    Thanks for the input, but not sure what to do with the points ...

    Accepted Solution

    PAQ'd, 500 points refunded.
    Community Support Moderator

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Introduction When many people think of the WebBrowser ( control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
    1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now