cancel
Showing results for 
Search instead for 
Did you mean: 

Crystal Reports keeps asking for database credentials

Former Member
0 Kudos

I created a Crystal Report using VS 2010 (CRforVS_13_0_4.exe was used to install CR for VS).  I have a class that I use for data access.  This class loads the data into variables that are public members of the class.  When I created the report using the Database Expert, I chose My Connections and selected the class I defined (CVLData) as the Table.  I then selected all the fields from the class that I need on the report.  When the user clicks a button to load the report, the data is loaded into the class for the report.  When the report is displayed I get an error: Database logon failed.  When I set EnableDatabaseLogonPrompt to True I get a prompt for database credentials.  Since the data is already loaded into the class I don't know why I am being prompted for database credentials.

I created a DataSet with the tables that I need for the report and used that as my DataSource.  I still am prompted for credentials.  I added the following code to set the credentials and I still have the problem.

protected void VerifyCVL_Click(object sender, EventArgs e)

{

     ReportDocument cryRpt = new ReportDocument();

     cryRpt.Load(Server.MapPath("test.rpt"));

     ConnectionInfo connectionInfo = new ConnectionInfo();

     connectionInfo.ServerName = "my server";

     connectionInfo.DatabaseName = "my db";

     connectionInfo.UserID = "userid";

     connectionInfo.Password = "password";

     SetDBLogonForReport(connectionInfo, cryRpt);

     CrystalReportViewer1.ReportSource = cryRpt;

     CrystalReportViewer1.RefreshReport();

}

private void SetDBLogonForReport(ConnectionInfo connectionInfo, ReportDocument reportDocument)

{

     Tables tables = reportDocument.Database.Tables;

     foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)

     {

          tableLogOnInfo tableLogonInfo = table.LogOnInfo;

          tableLogonInfo.ConnectionInfo = connectionInfo;

          table.ApplyLogOnInfo(tableLogonInfo);

     }

}

If I use a report that contains text and no data fields, the report displays fine without any prompt for credentials.  Can someone please tell me what I am doing wrong?

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

The most likely reason for the database prompts / errors is that the dataset is not what the report is expecting.

The connectionInfo code will never work as for a dataset there are no credentials...

I'd recommend having a look at the following:

Crystal Reports Guide To ADO.NET

Crystal Reports for Visual Studio 2005 Walkthroughs (this will apply to any version of CR)

Sample app csharp_win_adodotnet.zip here: http://wiki.sdn.sap.com/wiki/x/JQBmBQ

And for troubleshooting tips, see the blog Troubleshooting Issues with VS .NET Datasets and Crystal Reports

The developer help files may also help:

SAP Crystal Reports .NET API Guide

SAP Crystal Reports .NET SDK Developer Guide

Report Application Server .NET SDK Developer Guide

Report Application Server .NET API Guide

- Ludek

Follow us on Twitter

Got Enhancement ideas? Try the SAP Idea Place

Share Your Knowledge in SCN Topic Spaces

Former Member
0 Kudos

Thank you.  Using the Crystal Reports Guide to ADO.NET helped me resolve the problem.

Answers (0)