PC客户端上的C#Crystal Report总是询问登录提示SQL Server [英] C# Crystal Report on pc client always asking login prompt SQL Server

查看:74
本文介绍了PC客户端上的C#Crystal Report总是询问登录提示SQL Server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建我的程序,程序运行良好,可以填充数据库。

Create setup my program, the program runs well, can crud database.

打开报表时始终出现登录提示的问题。但是在数据库字段中则为空。

The problem when I open a report, the login prompt always appears. But in the database field was empty disable.

在服务器计算机上,没有报告任何问题。

On the server computer, reports no problems.

在我已建立连接的代码上,像这样

At the code I've made connection, like this

cnn.ServerName = @"179.15.30.74\SQLEXPRESS";
cnn.DatabaseName = "db_test";
cnn.UserID = "sa";
cnn.Password = "123";

如何禁用登录提示?

[已解决]
i在PC客户端
中安装sql native客户端 https://www.microsoft.com/zh-cn/download/details.aspx?id=16978

推荐答案

您必须设置要报告的参数,如下所示:

You must set parameter to report like this:

ReportDocument cryRpt = new ReportDocument();
TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();
Tables CrTables ;
cryRpt.Load("PUT CRYSTAL REPORT PATH HERE\CrystalReport1.rpt");
crConnectionInfo.ServerName = "YOUR SERVER NAME";
crConnectionInfo.DatabaseName = "YOUR DATABASE NAME";
crConnectionInfo.UserID = "YOUR DATABASE USERNAME";
crConnectionInfo.Password = "YOUR DATABASE PASSWORD";

CrTables = cryRpt.Database.Tables ;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
    crtableLogoninfo = CrTable.LogOnInfo;
    crtableLogoninfo.ConnectionInfo = crConnectionInfo;
    CrTable.ApplyLogOnInfo(crtableLogoninfo);
}

crystalReportViewer1.ReportSource = cryRpt;
crystalReportViewer1.Refresh(); 

这篇关于PC客户端上的C#Crystal Report总是询问登录提示SQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆