I have an application I have written in C#.net 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:
"cr.Database.Tables[0].SetDataSource(databaselocation);"
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)
{
InitializeComponent();
CrystalReport25 objRpt = new CrystalReport25();
objRpt.SetDataSource(ds.Tables[0]);
objRpt.SetDatabaseLogon("", "NH1admin");
objRpt.SetParameterValue("FromDate",startdate);
objRpt.SetParameterValue("ToDate",enddate);
CRViewer1.ReportSource = objRpt;
CRViewer1.Refresh();
}
Thanks you for any help you can provide.