我使用以下代码加载水晶报告。
ConnectionInfo crconnectioninfo = new ConnectionInfo();
ReportDocument cryrpt = new ReportDocument();
TableLogOnInfos crtablelogoninfos = new TableLogOnInfos();
TableLogOnInfo crtablelogoninfo = new TableLogOnInfo();
Tables CrTables;
crconnectioninfo.ServerName = "localhost";
crconnectioninfo.DatabaseName = "dbclients";
crconnectioninfo.UserID = "ssssssss";
crconnectioninfo.Password = "xxxxxxx";
cryrpt.Load(Application.StartupPath + "\\rpts\\" + dealerInfo.ResourceName);
CrTables = cryrpt.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
crtablelogoninfo = CrTable.LogOnInfo;
crtablelogoninfo.ConnectionInfo = crconnectioninfo;
CrTable.ApplyLogOnInfo(crtablelogoninfo);
}
cryrpt.RecordSelectionFormula = getCustInfoRptSelection();
cryrpt.Refresh();
allReportViewer.ReportSource = cryrpt;
getCustInfoRptSelection()正在获取特定客户端 但报告首次显示所有客户,当我关闭报告并再次打开报告时,它会显示正确的记录。 所以基本上我必须打开报告两次才能获得正确的数据,尽管getCustInfoRptSelection()结果没有改变。
在这种情况下,RecordSelectionFormula =" {dealer.dealer_type_id} = 2且{dealer.DEALER_NAME}喜欢' 马克档X '"
答案 0 :(得分:1)
我遇到了完全相同的问题,我在SAP网站上找到了this answer
展开Form1.vb|cs
以显示Form1.Designer.vb|cs
,然后双击它以显示其代码
查找crystalReportViewer1
方法
InitializeComponent
属性的位置
注释掉或删除以下两行:
this.crystalReportViewer1.SelectionFormula = ""
this.crystalReportViewer1.ViewTimeSelectionFormula = ""
显然,这是在其中一个较新的服务包中添加的内容,因为在我升级.Net的Crystal Reports框架之后,这个问题才开始发生
答案 1 :(得分:0)