I'm attempting to include a pre-created CrystalReport which links to a mysql database via a system DataSource (created by our designer) in our WPF application. However i've run into a roadblock, whenever the report is loaded in our application, it asks for database login, and fails to login even with valid information.
I have the following code:
string path = System.IO.Path.Combine(Environment.CurrentDirectory, @"FrontPageReport.rpt");
ReportDocument cryRpt = new ReportDocument();
cryRpt.Load(path);
ParameterFieldDefinitions crParameterFieldDefinitions;
ParameterFieldDefinition crParameterFieldDefinition;
ParameterValues crParameterValues = new ParameterValues();
ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();
//System.Net.NetworkCredential networkCredentials = new System.Net.NetworkCredential("ShippingClient", "1234", "domain");
cryRpt.SetDatabaseLogon("ShippingClient", "1234");
crParameterDiscreteValue.Value = shipmentID;
crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields;
crParameterFieldDefinition = crParameterFieldDefinitions["shipment_id"];
crParameterValues = crParameterFieldDefinition.CurrentValues;
crParameterValues.Clear();
crParameterValues.Add(crParameterDiscreteValue);
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
FrontPageReport.ViewerCore.ReportSource = cryRpt;
I have created a datasource which mirrors that of the CrystalReport using ODBC DataSource Administrator tool. However I still get the login popup that always fails.
Can anyone assist?
EDIT:
Turns out is has nothing to do with subreports infact it seems totally random which reports work and dont work, all using the dame database, same tables, same datasource, same login.
If i open the report in Visual Studio and click "Main Report Preview" i enter a valid paramter and it works like a charm, so why wont it work when the application is loaded?
Am i missing something major here?