Crystal Report Parameter Not Working
I m working in a windows base project with C# coding. I have used Crystal Report bundeled with Visual Studio 2005. This code I have written to solve issue of database server settings or when database location is changed. At the time of deployement of project at other location Crystal Report doesnât ask again for password and user id with this below mention code.
But after implementing this code I have found my parameters which are used to fatch record from SQLEXPRESS is not working. But parameter like Header value is displayed in the Report. Is there any solution any one is having for parameter value passed to SQLEXPRESS.
Please note that if I donât use last third line code then parameter works. But again the problem of deployment at client end arises.
âmyReportDocument.Database.Tables[0].ApplyLogOnInfo(LogInfo);â
I m using database expert for binding database stored procedure.
This is my code
LogInfo.ConnectionInfo.ServerName = "DataSource";
LogInfo.ConnectionInfo.UserID = "UserID";
LogInfo.ConnectionInfo.Password = "Password";
LogInfo.ConnectionInfo.DatabaseName = "Database";
To pass parameters in report I have written this code :
parameterDiscreteValue[0].Value = value ;
parameterField[0].ParameterFieldName = "@CustomerID";
parameterField[0].CurrentValues.Add(parameterDiscreteValue[0]);
parameterFields.Add(parameterField[0]);
parameterField[1].ParameterFieldName = "@Header";
parameterDiscreteValue[1].Value = " Report : Customer Details";
parameterField[1].CurrentValues.Add(parameterDiscreteValue[1]);
parameterFields.Add(parameterField[1]);
crystalReportViewer1.ParameterFieldInfo = parameterFields;
//to load report in document
myReportDocument.Load(REPORTLOCATION + "\\GenerateOrderListRep.rpt");
myReportDocument.Database.Tables[0].ApplyLogOnInfo(LogInfo);
//pass userid & Password
myReportDocument.SetDatabaseLogon(["UserID"],["Password"]);
//called report
crystalReportViewer1.ReportSource = myReportDocument;
|