Solved

Crystal Reports-logon failed error

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
A short film showing how OnPage and Connectwise integration works.

932 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

10 Experts available now in Live!

Get 1:1 Help Now