470,630 Members | 1,674 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,630 developers. It's quick & easy.

ASP.NET/Crystal Reports Logon Failed

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(lo gOnInfo)
Next i
myReport.Database.Tables(0).ApplyLogOnInfo(logOnIn fo)
myReport.Load()
CrystalReportViewer1.ReportSource = myReport
In both cases, I get the same error:

CrystalDecisions.CrystalReports.Engine.LogOnExcept ion: 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

Nov 19 '05 #1
9 6684
I think you need to load the report first and then provide the logon info.
>>>>>. myReport.Load()<<<<<<<<<<<<<<<<

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(lo gOnInfo)
Next i
myReport.Database.Tables(0).ApplyLogOnInfo(logOnIn fo) CrystalReportViewer1.ReportSource = myReport
HTH

<mo****@hotmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...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(lo gOnInfo)
Next i
myReport.Database.Tables(0).ApplyLogOnInfo(logOnIn fo)
myReport.Load()
CrystalReportViewer1.ReportSource = myReport
In both cases, I get the same error:

CrystalDecisions.CrystalReports.Engine.LogOnExcept ion: 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

Nov 19 '05 #2
Thanks for your quick response. Unfortunately, your suggestion didn't
work for either of the ways I'm trying.

Nov 19 '05 #3
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

<mo****@hotmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Thanks for your quick response. Unfortunately, your suggestion didn't
work for either of the ways I'm trying.

Nov 19 '05 #4
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.

Nov 19 '05 #5
crTables --is a collection of table object(i.e. crTable)

HTH

<mo****@hotmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
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.

Nov 19 '05 #6
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.ReportDocum ent
Dim crTable As CrystalDecisions.CrystalReports.Engine.Table
Dim crtableLogoninfo As CrystalDecisions.Shared.TableLogOnInfo
crReportDocument.Load(Server.MapPath("ProvidersLis t.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

Nov 19 '05 #7


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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #8
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.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #9


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

http://support.microsoft.com/default...en-us%3B319264

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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Bonj | last post: by
2 posts views Thread by Karun Karunakaran | last post: by
2 posts views Thread by GFro | last post: by
1 post views Thread by andy lim | last post: by
3 posts views Thread by Milan Todorovic | last post: by
3 posts views Thread by Shawn H. Mesiatowsky | last post: by
19 posts views Thread by Michael O'Donnell | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.