Why do I get "Database logon failed" in Crystal Reports when using .NET object as datasource?

If you are using ADO.NET DataSets as your datasource, it is possible for the DataSet definition to get out of sync with the definition in the report. Selecting the Database->Verify Database option from the report designer's context menu will often fix this problem.

Also, you will get this error if your report has linked tables and you fail to set the datasource for one of the tables. The fix is either to remove the table from the report, or set it's datasource correctly.

For example, if your report has a Customers table and an Orders table linked together on some key you will need to set the datasource for both tables. If you forget and set only one, you will get a "Database logon failure" error which is fairly misleading.

// Create a new customer orders report.
CustomerOrdersReport report = new CustomerOrdersReport();

// Get the report data.
DataTable customersTable = getCustomersData();
DataTable ordersTable = getOrdersData();

// Set datasources.
report.Database.Tables["Customers"].SetDataSource(customersTable);
report.Database.Tables["Orders"].SetDataSource(ordersTable ); // Don't forget this line like I did!!

Please try, Right-Click on Report -> Database-> Verify Database.

If dialog box appears, locate your DataSet .xsd file (e.g DataSet1.xsd) and Apply.

My problem solved in this way.


I started getting this dialog popping up after I changed the name of the .NET object my reports were referring to. To get rid the dialog, I had to ensure that none of my report sections or fields referred to the old name of the .Net object which was easy to spot. The fix for me was using the rename function in the Database Expert for the report.