p2p.wrox.com Forums

Need to download code?

View our list of code downloads.

  Return to Index  

aspx thread: Re: Logon Error in Crystal Reports (using SQL Server) in ASP.NET

Message #1 by tzarr@g... on Sun, 14 Jul 2002 00:59:03
You may have figured this out by now, but no one ever followed up, so I 
am posting this because I never found the correct answer online for my 
situation and I think people would appreciate it.

Here is the solution:

I have found that the error message "logon failed" was a very frustrating 
problem to deal with because it is just about impossible to trap 
using "try catch" blocks. I am new to .NET and was developing a set 
of .aspx pages using "codebehind" methods. After literally trying to trap 
the error in every way conceivable I realized that the problem was with 
the reports themselves. Apparently the reports must use ODBC or a trusted 
connection to get to the data source and generate the report and this is 
set up internally in the report and then registered somehow with the 
object during adding it through Visual Studio .NET. In my particular 
case, a database developer gave me the actual crystal .rpt files which 
called the necessary stored procedures.

What I found is that it is all in how you add them using Visual 
Studio .net.  If you drag them into your physical drive using windows 
explorer and then use the "add existing" option to add them to your 
project or source control, you will get a "logon failed message" after 
trying them. If you use the "add new" option in visual studio .net (by 
alternate clicking on the folder where you want to place the .rpt files) 
and then go browse for the .rpt files one by one it seems to go through 
some additional steps. It may ask for credentials or ask you to supply 
which ODBC DSN you would like to use. I am also suspicious that during 
this phase it does some actual registering of the report objects on a 
component level enabling them to be accessed through the Crystal Reports 
Viewer Control.

In my case, I did not find that this situation really had anything to do 
with setting up a domain user in the IIS anonymous access section or 
anything like that and I believe many of these posts and comments may be 
in error by people making assumptions. That sort of situation usually 
applies to IIS virtual directories and rights across different machines. 
I have not found that any of this applies to the Visual Studio .NET 
Crystal Reports viewer. I hope this helps because although the solution 
was ultimately very simple, I wasted a lot of time trying different 


> I'm trying to use the CrystalReportViewer control on an ASP.NET page to 
d> isplay an simple report based on data extracted from SQL Server 2000.  
c> an successfully create the report by working through the Crystal 
w> izard.  The wizard accepts my connection information and shows me the 
c> ontents of my database.  I can then pick and choose the data I want to 
s> how up on my report accordingly.  I places a CrystalReportViewer 
o> n an ASP.NET page (language is C#) and went on to databind the 
R> eportSource property to my report (for 
e> xample, "c:\\inetpub\\wwwroot\\project\\CrystalReport1.rpt").  When I 
t> ry to view the ASP.NET page in the browser, I consistently get the 
f> ollowing error: CrystalDecisions.CrystalReports.Engine.LogOnException: 
L> ogon failed.

> As an aside, the Crystal Reports example that ships with Microsoft.NET 
b> ased on data stored in a Microsoft Access database.  I can get this 
e> xample to display correctly using the CrystalReportViewer control on 
A> SP.NET page.

> Any help would be greatly apprecated.  

> Thanks,
M> ike P.

  Return to Index