1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| private void SetDBLogonForReport(ConnectionInfo connectionInfo)
{
TableLogOnInfos tableLogOnInfos = CrystalReportViewer1.LogOnInfo;
foreach (TableLogOnInfo tableLogOnInfo in tableLogOnInfos)
{
tableLogOnInfo.ConnectionInfo = connectionInfo;
}
}
private void ConfigureCrystalReports()
{
if (!IsPostBack)
{
string selectFormula = "{Param1} = \"Valeur1\" AND {Param2} = \"Valeur2\"";
CrystalReportViewer1.SelectionFormula = selectFormula;
}
string reportPath = Server.MapPath("Test2.rpt");
CrystalReportViewer1.ReportSource = reportPath;
ConnectionInfo connectionInfo = new ConnectionInfo();
connectionInfo.ServerName = "Serveur";
connectionInfo.DatabaseName = "Database";
connectionInfo.UserID = "Login";
connectionInfo.Password = "MotPasse";
SetDBLogonForReport(connectionInfo);
}
private void Page_Init(object sender, EventArgs e)
{
ConfigureCrystalReports();
} |
Partager