简体   繁体   English

Crystal Reports-报表无法与数据库连接

[英]Crystal Reports - report can't connect with database

I have issue with my report. 我的报告有问题。 I install my app on two PCs. 我在两台PC上安装了我的应用程序。 On first one I have SQL Server (MS SQL). 首先,我有SQL Server(MS SQL)。

On first PC reports works. 在第一台PC上,报告有效。 On second PC which is in same LAN report prompts me a window to set connection (which has empty, not editable database name box). 在同一局域网中的第二台PC上,报告会提示我设置连接的窗口(该窗口具有空的,不可编辑的数据库名称框)。

Report was created in Visual Studio 2017 with installed CRforVS 13.0.22 Client has installed CR runtime 13.0.22 I set connection programmatically using this code: 报表是在Visual Studio 2017中创建的,安装了CRforVS 13.0.22,客户端安装了CR运行时13.0.22,我使用以下代码以编程方式设置了连接:

SqlConnectionStringBuilder csb = new SqlConnectionStringBuilder(connectionString);

            DataSourceConnections dataSourceConnections = reportDocument.DataSourceConnections;
            foreach (IConnectionInfo connectInfo in dataSourceConnections)
            {
                if (csb.IntegratedSecurity)
                {
                    connectInfo.SetConnection(csb.DataSource, csb.InitialCatalog, true);
                }
                else
                {

                    connectInfo.SetConnection(csb.DataSource, csb.InitialCatalog, false);
                    connectInfo.SetConnection(csb.DataSource, csb.InitialCatalog, csb.UserID, csb.Password);
                    reportDocument.SetDatabaseLogon(csb.UserID, csb.Password);
                }
            }

            crystalReportViewer1.ReportSource = reportDocument;
            crystalReportViewer1.Zoom(1);

I don't know what am I missing. 我不知道我在想什么。 Any help will be appreciated. 任何帮助将不胜感激。

Adjust the host files of the affected computer. 调整受影响的计算机的主机文件。 Include the SQL Server Name and its IP. 包括SQL Server名称及其IP。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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