Crystal 报告和 C#
Crystal Report and C#
当我 运行 我的 C# windows form application that contains Crystal Report. It's asking me to enter the credential for the MySQL db every time. Even though I entered the correct user name and password. it is saying my user name or password is wrong。我已经检查了很多次凭据,输入的密码是正确的。
按照此说明操作。
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 report = new ReportDocument();
string reportPath = Server.MapPath("~/CrystalReport Path");
report.Load(reportPath);
Tables = report.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table table in Tables)
{
TableLogOnInfo = table.LogOnInfo;
TableLogOnInfo.ConnectionInfo = ConnectionInfo;
table.ApplyLogOnInfo(TableLogOnInfo);
}
CrystalReportViewer1.RefreshReport();
CrystalReportViewer1.ReportSource = report;
同时加载报表时,始终会设置连接字符串。
当我 运行 我的 C# windows form application that contains Crystal Report. It's asking me to enter the credential for the MySQL db every time. Even though I entered the correct user name and password. it is saying my user name or password is wrong。我已经检查了很多次凭据,输入的密码是正确的。
按照此说明操作。
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 report = new ReportDocument();
string reportPath = Server.MapPath("~/CrystalReport Path");
report.Load(reportPath);
Tables = report.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table table in Tables)
{
TableLogOnInfo = table.LogOnInfo;
TableLogOnInfo.ConnectionInfo = ConnectionInfo;
table.ApplyLogOnInfo(TableLogOnInfo);
}
CrystalReportViewer1.RefreshReport();
CrystalReportViewer1.ReportSource = report;
同时加载报表时,始终会设置连接字符串。