By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,680 Members | 1,436 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,680 IT Pros & Developers. It's quick & easy.

Getting logon error in Crystal Reports in ASP.Net

P: n/a
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.ReportDocum ent rp =
new CrystalDecisions.CrystalReports.Engine.ReportDocum ent();
rp.Load(Server.MapPath(".") + "\\StudentContactRoster.rpt");
for (int i = 0; i < rp.Database.Tables.Count; i++)
{
li = rp.Database.Tables[i].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[i].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.

Jul 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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.

"Mark Miller" wrote:
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.ReportDocum ent rp =
new CrystalDecisions.CrystalReports.Engine.ReportDocum ent();
rp.Load(Server.MapPath(".") + "\\StudentContactRoster.rpt");
for (int i = 0; i < rp.Database.Tables.Count; i++)
{
li = rp.Database.Tables[i].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[i].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.

Jul 21 '05 #2

P: n/a
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...b;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.

Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.