cancel
Showing results for 
Search instead for 
Did you mean: 

CrystalDecisions.CrystalReports.Engine.LogOnException: Logon failed.

Former Member
0 Kudos

Hi,

I am trying to use a crystal report in my web application (asp.net 2003 + CR Version 8.5)

I get this error: Exception Details: CrystalDecisions.CrystalReports.Engine.LogOnException: Logon failed.

I think its because this report has more than one datasource. So how can i Logon for a report which has more than one datasource.

Below is my code


Private Sub GetReportData()
        Try
	    Dim crReportDocument As New ReportDocument
            Dim ConnInfo As New ConnectionInfo
            With ConnInfo
                .ServerName = gbVariables.StrReportServer
                .DatabaseName = gbVariables.strReportDBName
                .UserID = gbVariables.strUsrName
                .Password = gbVariables.strUsrPwd
            End With
            crReportDocument.Load(gbVariables.strDocPathFolder + "\" + "XYZ.rpt")
            Me.CrystalReportViewer1.ParameterFieldInfo.Clear()
            Dim ParamFields As ParameterFields = Me.CrystalReportViewer1.ParameterFieldInfo

            'Set Month Paramter
            Dim GetMonthValues As Int16
            GetMonthValues = Session("Month")
            Dim Per As New ParameterField
            Per.ParameterFieldName = "@Month"
            Dim Month_Value As New ParameterDiscreteValue
            Month_Value.Value = GetMonthValues
            Per.CurrentValues.Add(Month_Value)
            ParamFields.Add(Per)

            Me.CrystalReportViewer1.ParameterFieldInfo = ParamFields
            Me.CrystalReportViewer1.ReportSource = crReportDocument

            crReportDocument.SetDatabaseLogon(gbVariables.strUsrName, gbVariables.strUsrPwd, gbVariables.StrReportServer, gbVariables.strReportDBName)
            
            Me.CrystalReportViewer1.RefreshReport()
            CrystalReportViewer1.Visible = True
        Catch ex As Exception
            lblError.Text = ex.Message.ToString
        End Try
    End Sub		

This is how i currently loginto database


crReportDocument.SetDatabaseLogon(gbVariables.strUsrName, gbVariables.strUsrPwd, gbVariables.StrReportServer, gbVariables.strReportDBName)

Thanks to help.

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

I would recommend looking at this White paper on how to logon to a database:

http://www.businessobjects.com/global/pdf/dev_zone/VS2005_Walkthroughs.pdf

Right now, looking at your code, it's quite convoluted. E.g.; you se the connection info, then load the report, then set it to the viewer, then do setdatabaselogon...

You may also want to see the sample app vbnet_win_dbengine sample app in this download:

https://smpdl.sap-ag.de/~sapidp/012002523100006252822008E/net_win_smpl.exe

Finally, I'd recommend that you search these forums as there are a number of great solutions here also.

Ludek

Answers (0)