[英]Crystal Report and C#
當我運行包含Crystal Report的C#Windows窗體應用程序時 。 它要求我每次輸入MySQL數據庫的憑據 。 即使我輸入了正確的用戶名和密碼。 這表示我的用戶名或密碼錯誤 。 我已經多次檢查憑證,並且輸入的密碼正確。
請遵循此說明。
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;
同時加載報告時,將始終設置連接字符串。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.