Crystal Reports 'Logon failed' problem

  • Thread starter Milan Todorovic
  • Start date
M

Milan Todorovic

Hello,

I need help. I have experience in ASP.NET programming, but this is my first
dealing with Crystal Reports. I'm trying to make the most basic report
purely for testing purposes: connect to the remote SQL DB and create a
report on one of the tables. Every time I do it, I get the Logon Failed
error (CrystalDecisions.CrystalReports.Engine.LogOnException: Logon failed)

The internet search shows that this is a common problem, especially for
those using the 'pull' method. In my case it occurs in both 'push' and
'pull' methods. The problem I guess lies in the lack of credentials to
connect to the data source (DB in this case). Most solutions mentions the
SetDatabaseLogon method, but that method does not belong to the
ReportDocument object even though the documentation shows that it should.
Even with all those solutions, I still haven't managed to solve my problem!
I have a feeling I'm missing something really obvious.

To explain what exactly I'm doing. In a project, I created the
CrystalReport1.rpt file, that connects to the SQL DB by specifying the
server, username and password (not using integrated security). In the
webform I created a CrystalReportViewer instance crv. In the code behind I
put the following code:

Dim rpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument()
rpt.Load("C:\\Inetpub\\wwwroot\\TestCrystal\\CrystalReport1.rpt")
crv.ReportSource = rpt
crv.DataBind()

What exactly do I need to do here to get this report to show? Any input is
greatly appreciated.

Thanks

Milan
 
C

chuckdfoster

I don't know if this will help or not, but it's worth a try. Depending on
the way you have the connection from your Crystal Report to your SQL Server,
you'll have to "log in" the Crystal Report. In other words, your Crystal
Report has to connect to the SQL Server someway. I added some code. Hope
it helps.

Dim tblCurrent As CrystalDecisions.CrystalReports.Engine.Table
Dim tliCurrent As CrystalDecisions.Shared.TableLogOnInfo
Dim strSel As String
Dim ClassID As Integer = 1
Try
'get report file and location from web.config
oRpt.Load(CS.AppSettings("RptLocation") & CS.AppSettings("RptFileName"))
Catch lex As LoadSaveReportException
lblError.Text = "Error loading the report" & vbCrLf & lex.Message
Catch ex As Exception
lblError.Text = "General Error" & vbCrLf & ex.Message
End Try
Try
'log the Crystal Report in
For Each tblCurrent In oRpt.Database.Tables
tliCurrent = tblCurrent.LogOnInfo
With tliCurrent.ConnectionInfo
'get log in info from web.config
.ServerName = CS.AppSettings("SQLServer")
.DatabaseName = CS.AppSettings("Database")
.UserID = CS.AppSettings("UserId")
.Password = CS.AppSettings("Password")
End With
'apply the log in info
tblCurrent.ApplyLogOnInfo(tliCurrent)
Next tblCurrent
Catch ex As Exception
lblError.Visible = True
lblError.Text = "Report Logon Error" & vbCrLf & ex.Message
End Try
Try
crv1.ReportSource = oRpt
Catch ex As Exception
lblError.Text = "Selection Error" & vbCrLf & ex.Message
End Try
End Sub
 
G

Guest

chuck, thanx for the code snipplet. I can't believe that C Reports is just as
messy since four years ago when i started to use them (deployng them via a
windows app).

The only thing with your code is that I can't figure out how to populate the
report with my dataset?

I've tried,
testr.SetDataSource(dstABC)
testr.Load(Server.MapPath("reportname1.rpt"))

but I get an error:
[LoadSaveReportException: Invalid report file path.]

Help???? This shouldn't have to be this hard. Thanx. (VB.NET)
 

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

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top