Skip to Content
Former Member
Feb 23, 2010 at 05:57 PM

How can I get a report to use a DSN instead of a database name?


DSNs are great things. By using a DSN in a database connection string, you don't have to worry about what happens if you have to look at a different database, or if a database name changes. All you have to do is change the database the DSN points to, and everything that was built using that DSN still works.

Everything, that is, except Crystal Reports.

I am using CR XI. Our customer's database is named "Anneal", and it uses PostgreSQL. I have several copies of that database, taken at different times and for different purposes, on my machine: "Anneal", "AnnealTest", "Anneal_2_8_10", and on and on. I also have a DSN named "WinCaps". The reorts I have developed for this customer were set up to use an ODBC connection based on the WinCaps DSN. But if WinCaps pointed to the "AnnealTest" database when it the report was created, and then I delete the AnnealTest database and change the WinCaps DSN to point to a database named "Anneal", and then try to open the report, I get a complaint that the AnnealTest database does not exist! Yes, I know it doesn't exist. I am expecting CR to use the DSN I told it to use, which should get me to the Anneal database.

The fact that CR complains about the AnnealTest database tells me that internally, CR is retrieving the actual name of the database and storing that instead of storing the DSN name, completely defeating the purpose of the DSN.

Is there any way I can set up my report to use whatever database the DSN happens to be pointing to, instead of the database the DSN pointed to at design time?

Thanks very much!

Rob Richardson