Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Authentication Failed

Status
Not open for further replies.

MichaelaLee

Programmer
May 3, 2004
71
US
Hi Everyone,
I've searched the forums here and have not found a solution that works yet. I hope you all can help.
I'm working with Crystal Reports 9 and "SQL Server 2000".
I'm getting the following error when trying to load a
report in VB:
Error from the Crystal Report viewer.
Logon Failed.
Details: ADO Error code: 0x80040e4d
Source: Provider
Description: Authentication Failed.
Native Error: -2147217843

The SQL Server is setup for Windows authentication and I'm trying to use the following code to load the report:

Set crxReport = crInventoryADO
Set ConnectionInfo = crxReport.Database.Tables(1).ConnectionProperties
ConnectionInfo.Item("Data Source") = "SQLSERVER"
ConnectionInfo.Item("Integrated Security") = True
ConnectionInfo.Item("Provider") = "SQLOLEDB.1"
ConnectionInfo.Item("Database") = "NF_Inventory"
ConnectionInfo.Item("UserId") = ""
'ConnectionInfo.Item("Password") = ""
Set CRXParamDefs = crxReport.ParameterFields
For Each CRXParamDef In CRXParamDefs
With CRXParamDef
If .ParameterFieldName = "@ProgramId" Then
.ClearCurrentValueAndRange
.AddCurrentValue Str(Var)
End If
End With
Next
CRViewer91.ReportSource = crxReport

I really hope someone can help. THanks
Michael
 
Could it be that the Windows Authentication is failing for the current Windows login?

The only other thing I see that might be an issue is this line:
[tt]
ConnectionInfo.Item("Database") = "NF_Inventory"
[/tt]
There isn't a Connection Properties attribute named "Database". If you're connecting to the same database/table as the original report, just comment out that line, and try to run it again.

If you're trying to switch databases at runtime, you can do it like this:
[tt]
crxReport.Database.Tables(1).Location = "NewDatabase.dbo.TableName"
[/tt]
This document has everything you need to know about using the ConnectionProperty objects:

-dave
 
Put this after 'End With' ... and before 'Next'
CRXParamDef.ApplyLogOnInfo(ConnectionInfo)


Here is my code:

Code:
   Private Sub btnPreviewBasicReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPreviewBasicReport.Click

        ' Objects used to set the proper database connection information
        Dim tbCurrent As CrystalDecisions.CrystalReports.Engine.Table
        Dim tliCurrent As CrystalDecisions.Shared.TableLogOnInfo

        ' Create a report document instance to hold the report
        Dim rptAirportSecurity As New ReportDocument

        Try
            ' Load the report
            rptAirportSecurity.Load("..\report1.rpt")

            ' Set the connection information for all the tables used in the report
            ' Leave UserID and Password blank for trusted connection
            For Each tbCurrent In rptAirportSecurity.Database.Tables
                tliCurrent = tbCurrent.LogOnInfo
                With tliCurrent.ConnectionInfo
                    .ServerName = "DB2004\PROD"
                    .UserID = "CRDataReader"
                    .Password = "putOneHere"
                    .DatabaseName = "SQLNorthwind"
                End With
                tbCurrent.ApplyLogOnInfo(tliCurrent)
            Next tbCurrent

            ' Set the report source for the crystal reports viewer to the report instance.
            crvBasic.ReportSource = "..\report1.rpt"

            ' Zoom to Page Width when the report opens
            crvBasic.Zoom(1)

        Catch Exp As LoadSaveReportException
            MsgBox("Incorrect path for loading report.", _
                    MsgBoxStyle.Critical, "Load Report Error")

        Catch Exp As Exception
            MsgBox(Exp.Message, MsgBoxStyle.Critical, "General Error")

        End Try
    End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top