If you have spent any amount of time with Crystal Reports along with any third party tool, you will would have come across the “database logon failed” error at least once.
On the face of it, this error is self-explanatory; your report is unable to log into the database. It can also manifest itself with a “failed to open connection” message.
There are times though when all the obvious checks such as making sure the provided user name and password are correct don’t work. What’s next?
In this article we will explore what else you can do to get around this error.
Check ODBC DSN
If your report uses one or more ODBC DSNs (Datasource Names), make sure that the DSN referred to in the report exists on the server that you are running the report on. More importantly, make sure that the DSN is created in the correct ODBC DSN area that matches the third party tool’s bitness (e.g. 32 vs 64 bit). In Windows, these exist in different places: c:\windows\system32\odbcad32.exe for 64 bit DSNs and c:\windows\system32\syswow64\odbcad32.exe for the 32 bit version). Alternatively, use the Windows search and search for “ODBC” and then pick “ODBC Data Sources (32-bit)”. In either version, the DSN must be created as a System DSN.
UNC Path Matters
File-based databases on mapped drives are great for convenience but unfortunately they disappear as soon as the user logs off. Most tools that run as services and require database access will fail because the mapped path specified in your report becomes invalid as soon as the user logs off. It is best practice to always specify any path in its full UNC form; instead of p:\my reports\ it should read \\myserver\reports\ my reports. This will ensure that the path is valid regardless of whether or not a user is logged onto to your server.
Sub-Reports
We love sub-reports in Crystal Reports especially those times when you need related data in the report but there is virtually no way to connect the main report’s tables to the rest of the data. One of the best features of sub reports is the fact they can connect to an entirely different set of data even if that data resides in a completely different database. For third party tools, it is important that if your subreport is using a separate data source from the main report, you need to specify the credentials for that data source.
Table-Level Login
Another really useful feature in Crystal Reports is that the main report can use related tables located in different databases or even servers. For example, the Customers table can be located in SERVERX and you can connect it to the Orders table located in SERVERY. Once again, if this is your report setup, you have to specify the credentials for each datasource otherwise you will get the Database Logon Failed error.
All the functionality discussed above and more are available today in remiCrystal and you can download the 14 day free trial from here.