Getting logon error in Crystal Reports in ASP.Net

G

Guest

I'm not sure why this is happening. I'm trying to run a late-bound report.
My original code looked like this:

TableLogOnInfo logOnInfo = new TableLogOnInfo ();
logOnInfo.ConnectionInfo.ServerName = "<server name>";
logOnInfo.ConnectionInfo.DatabaseName = "<dbname>";
logOnInfo.ConnectionInfo.UserID = "<user id>";
logOnInfo.ConnectionInfo.Password = "<password>";
logOnInfo.TableName = "Student";

CrystalReportViewer1.ReportSource = Server.MapPath(".") +
"\\StudentContactRoster.rpt";
CrystalReportViewer1.LogOnInfo.Add(logOnInfo);

I run it and get a logon error. I've checked everything, the server name,
database name, user ID, password, tablename, etc., and they all check out. I
use much the same parameters in the data adapters I use elsewhere in the
application, and they work.

I tried a different solution, suggested by a post-er on this newsgroup, and
came up with this:

TableLogOnInfo li = null;
CrystalDecisions.CrystalReports.Engine.ReportDocument rp =
new CrystalDecisions.CrystalReports.Engine.ReportDocument();
rp.Load(Server.MapPath(".") + "\\StudentContactRoster.rpt");
for (int i = 0; i < rp.Database.Tables.Count; i++)
{
li = rp.Database.Tables.LogOnInfo;
TableLogOnInfo logOnInfo = new TableLogOnInfo();
li.ConnectionInfo.ServerName = "<server name>";
li.ConnectionInfo.DatabaseName = "<dbname>";
li.ConnectionInfo.UserID = "<user id>";
li.ConnectionInfo.Password = "<password>";
rp.Database.Tables.ApplyLogOnInfo(li);
}

StudentContactRosterReportViewer.ReportSource = rp;

I run this, using the same parameters as the first code block, and also get
a logon error. Anyone got some clues about what's going on here?

Thanks.
 
G

Guest

I should also mention that I'm using SQL Server 2000 as the database for this
report, and that I'm using VS.Net 2003. Unfortunately I don't know which
version of Crystal Reports was used to create the report, since it was
created by another contractor. Is that important to solving the problem? I
do know that the report designer used SQL Server 2000 as his database as
well. So I don't think it's a driver issue.
 
G

Guest

I finally figured out how to fix my problem with this, and thought I'd share
it since many other people have run into similar problems.

Microsoft has an article on this issue at:

http://support.microsoft.com/default.aspx?scid=kb;en-us;319264

This is Microsoft's answer to the problem. They basically say you need to
set up your LogOnInfo and ConnectionInfo inside your ASP.Net code, and then
go through each table in the report's document and set the LogOnInfo and
ConnectionInfo for each individually. This is "by design" for security
reasons. I put in the code they said to use for this issue, but it didn't
totally solve the problem.

What I ultimately had to do was go bring up the .rpt file in VS.Net,
right-click in the report, and go to Database|Verify Database... This
brought up a wizard which allowed me to view/enter connection parameters such
as database name, login settings, and the database name. The wizard allowed
me to try connecting using the existing parameters and it didn't work. The
report itself was set to the wrong server name, and was set to use Integrated
Windows Authentication. I thought by assigning my own datasource
information, connection information, etc. that it would override what was
programmed into the report. It turns out it doesn't.

I used the wizard to set the report's server name to the correct name, and
turned off Windows Authentication, and put in the correct user ID and
password information. This changed the connection and logon information for
the report itself, the .rpt file. I was able to test these parameters in the
wizard, and they worked. Only then, when I ran my ASP.Net app. did the
report finally work.
 

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

Top