传递UserName和Password后,crystal report仍然需要UserNmae和Password [英] crystal report still need the UserNmae and Password after pass the UserName and Password

查看:92
本文介绍了传递UserName和Password后,crystal report仍然需要UserNmae和Password的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Report.ReportCatProducts rcp = new Report.ReportCatProducts();

rcp.SetDatabaseLogon(pc1,12,Server,MnStores,false);

rcp.SetParameterValue(@ catId,this.dataGridView1.CurrentRow.Cells [0] .Value.ToString());

Report.FormCatProducts2 fcp2 = new Report.FormCatProducts2() ;

fcp2.crystalReportViewer1.ReportSource = rcp;

fcp2.ShowDialog();

Report.ReportCatProducts rcp = new Report.ReportCatProducts();
rcp.SetDatabaseLogon("pc1", "12", "Server", "MnStores", false);
rcp.SetParameterValue("@catId",this.dataGridView1.CurrentRow.Cells[0].Value.ToString());
Report.FormCatProducts2 fcp2 = new Report.FormCatProducts2();
fcp2.crystalReportViewer1.ReportSource = rcp;
fcp2.ShowDialog();

推荐答案

我认为您必须提供报告源中涉及的所有表的登录信息。请参阅以下可能对您有帮助的代码。

注意:出于安全目的,连接安全信息必须以不同的方式提供,而不是如下所述(密码和服务器信息不应直接输入,如下面的代码所示 - 我只使用它简化了事情)。同样,如果要为源指定参数,您可以像在执行此操作一样。



I think you will have to provide logon info for all the tables involved within your report source. Please see code below which might help you.
Note: The connection security information must be supplied in a different way rather than as specified below for security purpose (Passwords and server info should not be typed directly as shown in the code below - I am only using it to simplify things). Again, if you want to specify parameters to the source, you can as you are doing it.

ReportDocument report = new ReportDocument();
                    TableLogOnInfo logoninfo = new TableLogOnInfo();
                    ConnectionInfo connectioninfo = new ConnectionInfo();
                    Tables tables;

                    connectioninfo.ServerName = "<Your Database Server Name>"
                    connectioninfo.DatabaseName = "<Your Database Name>";
                    connectioninfo.UserID = "<Your Database User>";
                    connectioninfo.Password = "<Your Database User Password";
                    
	      string ReportPath = Server.MapPath("TempReport.rpt");

                    report.Load(ReportPath);
                    tables = report.Database.Tables;

                    foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
                    {
                        logoninfo = table.LogOnInfo;
                        logoninfo.ConnectionInfo = connectioninfo;
                        table.ApplyLogOnInfo(logoninfo);
                    }

                    this.crysreportviewer.ReportSource = report;
                    crysreportviewer.RefreshReport();


这篇关于传递UserName和Password后,crystal report仍然需要UserNmae和Password的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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