using System.Data.SqlClient; // brauchte für Datenbank
using CrystalDecisions.CrystalReports.Engine; //needed für dynamischen Kristall
Schnur reportName = Schnur. Leer;
statische ConnectionStringSettings conSettings = ConfigurationManager.ConnectionStrings [„WannalancitConnectionString“];
geschütztes leeres Page_Prerender (Gegenstandabsender, EventArgs e)
{
reportName = (Schnur) Pufferspeicher [„CrystalRptName“];
wenn (! IsPostBack)
{
CrystalReportSource1.Report.FileName = reportName;
}
wenn (reportName.IndexOf („testuntrained.rpt“) > -1)
{
setDynamicDB ();
}
wenn (CrystalReportSource1.Report.FileName! = reportName)
CrystalReportSource1.Report.FileName = reportName;
}
geschütztes leeres btnBack_Click (Gegenstandabsender, EventArgs e)
{
Response.Redirect („f_MenuReports.aspx“);
}
privates leeres setDynamicDB ()
{
Versuch
{
Schnur conStr = System.Configuration.ConfigurationManager.AppSettings [„WannalancitConnectionString“];
Schnur strReportPath = Server.MapPath („~/Reports/testuntrained.rpt“);
//SqlConnection sqlConnection = neues SqlConnection (conStr);
Schnur connectionInfo = conSettings.ConnectionString;
SqlConnection sqlConnection = neues SqlConnection (connectionInfo);
SqlCommand Befehl = neues SqlCommand ();
Command.Connection = sqlConnection;
Command.CommandText = „UnTrainedReport“;
Command.CommandType = CommandType.StoredProcedure;
SqlDataAdapter Adapter = neues SqlDataAdapter (Befehl);
dsUntrainedRpt ds = neues dsUntrainedRpt ();
Adapter.Fill (ds, „UntrainedReport“);
ReportDocument Cr = neues ReportDocument ();
Cr. Last (strReportPath);
cr.SetDataSource (ds. Tabellen [„UntrainedReport“]);
CrystalReportViewer1.ReportSource = Cr;
}
Fang (Ausnahme exp)
{
lblErrorMsg.Text = exp. Mitteilung;
}
}
}
|