I've written a C# (2.0) Windows application which has a Crystal report that pulls it's data from a stored procedure (with one input parameter) from SQL Server 2005 Express.
Report works on the development computer.
But when deployed to another computer, my code to set the database server name does not work. Instead, it prompts me with a dialog box to enter the connection parameters, but the server name and database names are greyed out (and set to my development machine).
Here is my code:
I've confirmed that my GetServerName() function is returning the correct server name from message boxes I've placed in the code.
Report works on the development computer.
But when deployed to another computer, my code to set the database server name does not work. Instead, it prompts me with a dialog box to enter the connection parameters, but the server name and database names are greyed out (and set to my development machine).
Here is my code:
Code:
private void ConfigureCrystalReports()
{
ConnectionInfo connInfo = new ConnectionInfo();
ReportDocument oRpt = new ReportDocument();
oRpt.Load(Application.StartupPath + "\\BOL_Printout.rpt");
CrystalDecisions.Shared.TableLogOnInfo crLogonInfo;
crLogonInfo = oRpt.Database.Tables[0].LogOnInfo;
crLogonInfo.ConnectionInfo.ServerName = GetServerName();
crLogonInfo.ConnectionInfo.UserID = GetUserName();
crLogonInfo.ConnectionInfo.Password = GetPassword();
crLogonInfo.ConnectionInfo.DatabaseName = GetDatabaseName();
oRpt.Database.Tables[0].ApplyLogOnInfo(crLogonInfo);
CrystalVwr.ReportSource = oRpt;
ParameterDiscreteValue parameterDiscreteValue = new ParameterDiscreteValue();
parameterDiscreteValue.Value = BOL_ID.ToString();
ParameterValues currentParameterValues = new ParameterValues();
currentParameterValues.Add(parameterDiscreteValue);
CrystalVwr.ParameterFieldInfo[0].CurrentValues = currentParameterValues;
}
private void frmPrintout_Load(object sender, EventArgs e)
{
ConfigureCrystalReports();
}
I've confirmed that my GetServerName() function is returning the correct server name from message boxes I've placed in the code.