繁体   English   中英

水晶报表和C#

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM