Click here to Skip to main content
14,695,504 members
Please Sign up or sign in to vote.
0.00/5 (No votes)

I have an application I have written in using VS 2008 and an Access database. I am using Crystal Reports (basic) for reporting. The way I have generated my reports, I bring up a windows form that lets the user select what they want to report on (date ranges, data points, groupings, totals, etc) and then I generate a SQL statement and grab the data I need from the database and pass the dataset to the "Windows Form" that contains the CR Viewer and then open the required report based on the data requested.

In my development enviornment, everything works great.

When I deploy the application to another system for testing, I can still generate the dataset, but when I try to bind the data to the report, the report goes out and looks for the database at the location where the database was located on my development system for some reason. I can't seem to get around this although I assume it has a simple solution. The location where it looks for the database is where I set it in VS when I created the report from the "Crystal Reports \ database \ Set database location " menu strip.

How do I get the report to simply use the dataset I am sending it and not search for the database; or get it to look for the database where the user has installed it (I have this information saved in both the config file and the registry)

I have been searching through google and forums for 2 days looking for a solution and although there seems to be ways to modify the database location using commands like:


and other similar ones, I can't get anything to work for me.

Here is the basic code I am using in my Windows form:

public Report19(DataSet ds, string startdate, string enddate)
      CrystalReport25 objRpt = new CrystalReport25();
      objRpt.SetDatabaseLogon("", "NH1admin");
      CRViewer1.ReportSource = objRpt;

Thanks you for any help you can provide.

1 solution

Have a look at the Table.LogOnInfo Property[^]
pgeorge33 10-Jan-12 15:34pm
Thanks! So far it seems to be working. (I hard coded it into 1 report) Not sure how I missed that one...
pgeorge33 10-Jan-12 15:44pm
I just deployed the hard coded version to a test machine and it works like a champ! Thanks for all of your help.
Wendelius 10-Jan-12 15:45pm
You're welcome :)
pgeorge33 11-Jan-12 9:21am
Hi All,

It turns out this solution works for some of my reports but not for others! I suspect there may a setting someplace in the report that prohibits Table.LogOnInfo settings from being executed. I have been scouring the files that do work and comparing them to those that don't and have come up empty so far. Any ideas where this parameter might be?

BTW, the changes seem to work on all reports on my development system... But only some of them on the deployed system...
pgeorge33 11-Jan-12 10:59am
Hold the phone! Looks like an installation code issue... Running from the wrong location... Dah!!!
Wendelius 11-Jan-12 11:29am
So it seems to work now?
pgeorge33 11-Jan-12 14:41pm
Ypu, works great.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900