Solved

Crystal Reports-logon failed error

Posted on 2004-09-24
5
1,397 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
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

706 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now