Solved

Crystal Reports-logon failed error

Posted on 2004-09-24
5
1,403 Views
Last Modified: 2012-06-21
whenver i design a crystal report from within dot net environment, it gives me this error
CrystalDecisions.CrystalReports.Engine.LogOnException: Logon failed.
the code i have used is as follows:

Dim rpt As ReportDocument
        rpt = New ReportDocument
        CrystalReportViewer1.DataBind()
        rpt.Load("c:\inetpub\wwwroot\west\reports\rep1.rpt", OpenReportMethod.OpenReportByDefault)
        rpt.SetDatabaseLogon("sa", "123", "server1", "eastdb")
        CrystalReportViewer1.ReportSource = rpt
        CrystalReportViewer1.ShowFirstPage()
somebody please tell me, where i m wrong!!!
0
Comment
Question by:Heritagecomputer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 42

Expert Comment

by:frodoman
ID: 12142204
One thing about "SetDatabaseLogon" is that it only works if you're connecting to the same db that was used to design the report - if you're connection to another db (say a production vs. development) then this method will not work (ref: http://support.businessobjects.com/library/kbase/articles/c2013545.asp).

Otherwise the obvious thing is to check that the credentials are accurate - I don't see any problem with the code itself.

frodoman
0
 
LVL 42

Expert Comment

by:frodoman
ID: 12142210
If your report involves subreports then you may need a hotfix: http://support.businessobjects.com/library/kbase/articles/c2012317.asp

frodoman
0
 
LVL 1

Expert Comment

by:srini5474
ID: 12158467
this is no problem with your application, every time u newly connect/Edit Existing  DB using CrystalReporter... Do the following..................
Open ur Crystal reporter.
open field Explorer
Right click Database fields tree menu.
click on verify Database.
and click ok on following pop up windows. Ur DB will be refreshed..

i suppose ur problem should have been solved by now :-)

Regards
Srinivasan.S
0
 
LVL 10

Accepted Solution

by:
ebolek earned 250 total points
ID: 12160243
I use this code and it works try it
This code will help you.
private void setlogoninfo(CrystalDecisions.CrystalReports.Engine.ReportDocument myreport)
{
CrystalDecisions.Shared.TableLogOnInfo MyLogonInfo;
foreach(CrystalDecisions.CrystalReports.Engine.Table MyTable in myreport.Database.Tables)
{
MyLogonInfo = MyTable.LogOnInfo;
if (MyTable.Name == "")
{
MyLogonInfo.ConnectionInfo.UserID = this._username;
MyLogonInfo.ConnectionInfo.Password = this._password;
MyLogonInfo.ConnectionInfo.ServerName  = this._servername;  
MyLogonInfo.ConnectionInfo.DatabaseName = this._databasename ;              
{
else
{
               
MyLogonInfo.ConnectionInfo.UserID = this._username;
MyLogonInfo.ConnectionInfo.Password = this._password;
MyLogonInfo.ConnectionInfo.ServerName  = this._servername;  
MyLogonInfo.ConnectionInfo.DatabaseName = this._databasename ;
}
MyTable.ApplyLogOnInfo(MyLogonInfo);                    
MyTable.Location = MyTable.Location.Substring(MyTable.Location.LastIndexOf(".")+1);  
     
}
}          
Regards
Emre
0
 

Author Comment

by:Heritagecomputer
ID: 12890111
Thanks.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question