I have a report that is atched to a database (using a store procediture) I want to change the database connection at run time, but when I change the database the parameters are not passed and viseversa. Please help me with any idea. This is the code I am using:
(C_App is the database name I want to set up, but everytime the report grabs the default database SM_App)
ReportDocument myDataReport = new ReportDocument();
myDataReport.Load(
"C:\\Report.rpt");
CrystalDecisions.Shared.
TableLogOnInfo myInfo;
crview.LogOnInfo =
new TableLogOnInfos();
myInfo =
new TableLogOnInfo();
myInfo.ConnectionInfo.ServerName =
"DAtabaseName";
myInfo.ConnectionInfo.DatabaseName =
"C_App";
myInfo.ConnectionInfo.UserID =
"sa";
myInfo.ConnectionInfo.Password =
"password";
myDataReport.SetParameterValue(
"@parameter1", "value1");
myDataReport.SetParameterValue(
"@parameter2", "value2");
CrystalReportViewer1.LogOnInfo.Add(myInfo);
CrystalReportViewer1.ReportSource = myDataReport;
}