We help IT Professionals succeed at work.
Get Started

Using the .NET Crystal Report Viewer to display a report

Last Modified: 2012-05-11
I have a bad feeling that I am not going to get any responses to this post but here goes.  The folowing code was working perfectly just 1 month ago and never prompted for a password.  In this example, I have a single report with one database table and no parameters.  When I run this code, the form with the report viewer opens and pops up a small Database Login window with all of the fields populated.  I click Ok and it says:

Login failed.  Please try again.

I re-type the password and it still fails.  I am 100% sure that the credentials are correct and If I run the report in Crystal Reports with the exact same credentials, the report runs as expected.  

The application is running on one machine and the report resides in a folder on the SQL Server.  This is happening with all reports that connect to a database.  I have literaly spent the entire day researching this and have seen many, many posts like this but little or no suggestions and it there are any, they don't work.

ReportDocument reportDoc = new ReportDocument();

ConnectionInfo connectionInfo = new ConnectionInfo();
connectionInfo.UserID = userName;
connectionInfo.Password = password;
connectionInfo.ServerName = odbcName;
connectionInfo.DatabaseName = databaseName;
foreach (Table table in reportDoc.Database.Tables)
  TableLogOnInfo tableLogonInfo = table.LogOnInfo;
  tableLogonInfo.ConnectionInfo = connectionInfo;

crystalReportViewer1.ReportSource = reportDoc;

Open in new window

Watch Question
This problem has been solved!
Unlock 3 Answers and 21 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE