简体   繁体   English

水晶报表:无法连接:错误的登录参数

[英]Crystal report: Unable to connect: incorrect log on parameters

This is the code of Crystal Report: 这是Crystal Report的代码:

    ReportDocument reportDocument = new ReportDocument();
    reportDocument.Load(Server.MapPath(ReportName + ".rpt"));
    reportDocument.SetParameterValue("@userid", Convert.ToInt64(5));
    reportDocument.SetParameterValue("@Reportname", ReportName);
    reportDocument.SetParameterValue("@SessionId", Session.SessionID.ToString());
    CrystalReportViewer1.ReportSource = reportDocument;
    reportDocument.SetDatabaseLogon("sa", "Password1", "192.168.0.245", "databaseName", true);

It is saying "Unable to connect: incorrect log on parameters." 它说“无法连接:错误的登录参数”。 although the login information is correct. 尽管登录信息正确。

If I set the value to "reportDocument.SetDatabaseLogon("sa", "Password1", "192.168.0.240", "databaseName", true);" 如果我将值设置为“ reportDocument.SetDatabaseLogon(“ sa”,“ Password1”,“ 192.168.0.240”,“ databaseName”,true);“ it is working fine which is the login information was given during the designing the Crystal Report. 运行正常,这是在设计Crystal Report时提供的登录信息。

Can try this and see if it helps? 可以尝试一下,看看是否有帮助?

       ConnectionInfo connectionInfo = new ConnectionInfo
                                            {
                                                UserID = user, 
                                                Password = pwd, 
                                                ServerName = server, 
                                                DatabaseName = db
                                            };
        TableLogOnInfo tableLogOnInfo = new TableLogOnInfo
                                            {
                                                ConnectionInfo = connectionInfo
                                            };
        foreach (Table table in reportDocument.Database.Tables)
        {
            table.ApplyLogOnInfo(tableLogOnInfo);
        }

I have same problem but has solved. 我有同样的问题,但已经解决了。

The problem is in odbc connection. 问题出在odbc连接中。 Just install SQL native client to add connection in odbc. 只需安装SQL本机客户端即可在odbc中添加连接。 Download link https://support.fotoware.com/hc/en-us/articles/208664385-Microsoft-SQL-Native-Client-fails-to-download-during-FotoWeb-setup 下载链接https://support.fotoware.com/hc/en-us/articles/208664385-Microsoft-SQL-Native-Client-fails-to-download-during-FotoWeb-setup

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

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