ASP.NET/Crystal Reports Logon Failed

M

mollyf

I have tried various suggestions that I have found searching the
newsgroups and still haven't been able to figure why I keep getting the
logon failed error.

I created a report in Crystal (not via VS 2003). The data source to
the report is a stored procedure (SQL S2K) that has no parameters. I'm
also using SQL Server authentication to log in.

I added the report to my project (as was suggested recently by someone
in a different thread). I have tried the following code:

Dim myReport As New ProvidersList

Dim conStrBH As String =
ConfigurationSettings.AppSettings("conStrBH")
Dim cnn As SqlConnection = New SqlConnection(conStrBH)
Dim cmd As New SqlCommand
Dim ProvIDParam As New SqlParameter
Dim i As Integer

cnn.Open()
cmd.Connection = cnn
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "sp_GetProviders"

myReport.Database.Tables(0).SetDataSource(cmd)
myReport.Load()
CrystalReportViewer1.ReportSource = myReport
cnn.Close()

conStrBH is a connection string located in the web.config and is used
throughout the app. There is no problem with the connection string as
I wouldn't be able to log into the web app if there was a problem
there.

I've also tried the following code, which is similar to what VS help
showed.

Dim myReport As New ProvidersList
Dim logOnInfo As New TableLogOnInfo
Dim i As Integer

For i = 0 To myReport.Database.Tables.Count - 1
' Set the connection information for current table.
logOnInfo.ConnectionInfo.ServerName = "servername"
logOnInfo.ConnectionInfo.DatabaseName = "databasename"
logOnInfo.ConnectionInfo.UserID = "username"
logOnInfo.ConnectionInfo.Password = "password"

myReport.Database.Tables.Item(i).ApplyLogOnInfo(logOnInfo)
Next i
myReport.Database.Tables(0).ApplyLogOnInfo(logOnInfo)
myReport.Load()
CrystalReportViewer1.ReportSource = myReport


In both cases, I get the same error:

CrystalDecisions.CrystalReports.Engine.LogOnException: Logon failed.

I'm doing this on my local machine running Win XP Pro. Any help would
be appreciated.

Thanks.

Molly J. Fagan
Oklahoma Foundation for Medical Quality
 
V

Vaibhav

I think you need to load the report first and then provide the logon info.
For i = 0 To myReport.Database.Tables.Count - 1
' Set the connection information for current table.
logOnInfo.ConnectionInfo.ServerName = "servername"
logOnInfo.ConnectionInfo.DatabaseName = "databasename"
logOnInfo.ConnectionInfo.UserID = "username"
logOnInfo.ConnectionInfo.Password = "password"

myReport.Database.Tables.Item(i).ApplyLogOnInfo(logOnInfo)
Next i
myReport.Database.Tables(0).ApplyLogOnInfo(logOnInfo)
CrystalReportViewer1.ReportSource = myReport

HTH
 
M

mollyf

Thanks for your quick response. Unfortunately, your suggestion didn't
work for either of the ways I'm trying.
 
V

Vaibhav

mentioned below is my code which work fine on my machine. code is invoked
from within
Private Sub Page_Init()

crReportDocument.Load(Server.MapPath("crXYZ.rpt"),
OpenReportMethod.OpenReportByTempCopy)

With crConnectionInfo

.ServerName = "XYZ"

.DatabaseName = "SOMEDB"

.UserID = "SOMEUSERID"

.Password = "SOMEPASS"

End With

crTables = crReportDocument.Database.Tables

'sets connection info. for database tables

For Each crTable In crTables

crtableLogoninfo = crTable.LogOnInfo

crtableLogoninfo.ConnectionInfo = crConnectionInfo

crTable.ApplyLogOnInfo(crtableLogoninfo)

Next

'sets the report source

CrystalReportViewer1.ReportSource = crReportDocument

End Sub

HTH
 
M

mollyf

What kind of objects are crTables and crTable? I found some code
similar to yours and guessed at what types they could be but still
haven't had any luck.

Thanks so much for your help.
 
M

mollyf

I'm still getting the logon failed error. Below is all of my code. I
no longer have the report as part of the project. Is there something
that I need to do to the server to make it work? I'm hitting the
database to log into my web app but I don't know if there's additional
steps needed for Crystal that I'm missing or what.

Thanks for your help.


Dim crConnectionInfo As New
CrystalDecisions.Shared.TableLogOnInfo
Dim crTables As CrystalDecisions.CrystalReports.Engine.Tables
Dim crReportDocument As New
CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim crTable As CrystalDecisions.CrystalReports.Engine.Table
Dim crtableLogoninfo As CrystalDecisions.Shared.TableLogOnInfo
crReportDocument.Load(Server.MapPath("ProvidersList.rpt"),
OpenReportMethod.OpenReportByTempCopy)

With crConnectionInfo.ConnectionInfo
.ServerName = "server"
.DatabaseName = "database"
.UserID = "user"
.Password = "password"
End With

crTables = crReportDocument.Database.Tables

'sets connection info. for database tables

For Each crTable In crTables
crtableLogoninfo = crTable.LogOnInfo
crtableLogoninfo.ConnectionInfo =
crConnectionInfo.ConnectionInfo
crTable.ApplyLogOnInfo(crtableLogoninfo)
Next

'sets the report source

CrystalReportViewer1.ReportSource = crReportDocument
 
S

Stacy Dudas

I am having a similar issue. I am using Crystal Reports 10 and Delphi
7. My development database is different than my production database.
In previous versions of Crystal (9 and 8.5) I was able to delete the DSN
and table owner from the Crystal application - Database | Set Location,
Table edit box on the bottom of the screen.
ie. from dsn_name.dbo.tablename to tablename

This worked with my production and development reports when called
through Delphi.

Crystal 10 does not allow the changing of the table under the set
location. I am receiving the "Logon failed" error as well.

Do you have any suggestions?

Thanks,
Stacy
 
N

Nate Papineau

I was getting the same error when using the ApplyLogOnInfo method
against a stored proc.

I gave execute permissions for the user i was logging on as to the
stored proc (should have done that in the first place but forgot) and it
worked.

Hope that helps.
 
J

Joseph Bowen

This problem is bedeviling me too. Here is a Microsoft note on the
issue:

http://support.microsoft.com/default.aspx?scid=kb;en-us;319264

Beware, their example code is written in C#.

But, this doesn't fix my problem. I am working within VS, and created
the report and the webpage with the report viewer in the designer. I
theorize that the report I'm setting the logon info for is not the same
instance as the report that is being shown, the one created in the
designer. Anybody familiar with this issue?

I've tried
setting logon userid/pw
changing ASPNET user's permissions
try/catch statements
and am lost. Any thoughts welcome.

Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top