就我而言,如何在 Asp.Net C# 中为 Crystal 报告创建动态连接字符串?
How to create dynamic connection string for Crystal Report in Asp.Net C# in my case?
我有多个 iis,所有 iis 网页都连接不同的数据库。我有太多Crystal 报告,一旦我将它上传到所有多个iis,它必须连接到相应的数据库。
我不知道要在 crystal 报告中创建连接字符串。
这是我的 ReportViewer 代码
protected void CrystalReportViewer1_Init(object sender, EventArgs e)
{
ReportDocument _rdStudents = new ReportDocument();
Trace.Write("/CrystalReportFiles/RMS/Inventory/");
string reportPath = Server.MapPath("~" + Request.QueryString["filename"].ToString());
_rdStudents.Load(reportPath);
CrystalReportViewer1.ReportSource = _rdStudents;
}
如何在这里创建连接字符串。我看到了其中的一些 link。但是我没看懂。
关注这个。
TableLogOnInfos TableLogOnInfos = new TableLogOnInfos();
TableLogOnInfo TableLogOnInfo = new TableLogOnInfo();
ConnectionInfo ConnectionInfo = new ConnectionInfo();
Tables Tables;
ConnectionInfo.ServerName = "ServerName";
ConnectionInfo.DatabaseName = "Database";
ConnectionInfo.UserID = "UserId";
ConnectionInfo.Password = "Password";
ReportDocument _rdStudents = new ReportDocument();
Trace.Write("/CrystalReportFiles/RMS/Inventory/");
string reportPath = Server.MapPath("~" + Request.QueryString["filename"].ToString());
_rdStudents.Load(reportPath);
Tables = _rdStudents.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table table in Tables)
{
TableLogOnInfo = table.LogOnInfo;
TableLogOnInfo.ConnectionInfo = ConnectionInfo;
table.ApplyLogOnInfo(TableLogOnInfo);
}
CrystalReportViewer1.RefreshReport();
CrystalReportViewer1.ReportSource = _rdStudents;
我有多个 iis,所有 iis 网页都连接不同的数据库。我有太多Crystal 报告,一旦我将它上传到所有多个iis,它必须连接到相应的数据库。
我不知道要在 crystal 报告中创建连接字符串。
这是我的 ReportViewer 代码
protected void CrystalReportViewer1_Init(object sender, EventArgs e)
{
ReportDocument _rdStudents = new ReportDocument();
Trace.Write("/CrystalReportFiles/RMS/Inventory/");
string reportPath = Server.MapPath("~" + Request.QueryString["filename"].ToString());
_rdStudents.Load(reportPath);
CrystalReportViewer1.ReportSource = _rdStudents;
}
如何在这里创建连接字符串。我看到了其中的一些 link。但是我没看懂。
关注这个。
TableLogOnInfos TableLogOnInfos = new TableLogOnInfos();
TableLogOnInfo TableLogOnInfo = new TableLogOnInfo();
ConnectionInfo ConnectionInfo = new ConnectionInfo();
Tables Tables;
ConnectionInfo.ServerName = "ServerName";
ConnectionInfo.DatabaseName = "Database";
ConnectionInfo.UserID = "UserId";
ConnectionInfo.Password = "Password";
ReportDocument _rdStudents = new ReportDocument();
Trace.Write("/CrystalReportFiles/RMS/Inventory/");
string reportPath = Server.MapPath("~" + Request.QueryString["filename"].ToString());
_rdStudents.Load(reportPath);
Tables = _rdStudents.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table table in Tables)
{
TableLogOnInfo = table.LogOnInfo;
TableLogOnInfo.ConnectionInfo = ConnectionInfo;
table.ApplyLogOnInfo(TableLogOnInfo);
}
CrystalReportViewer1.RefreshReport();
CrystalReportViewer1.ReportSource = _rdStudents;