<i id='TxDvV'><tr id='TxDvV'><dt id='TxDvV'><q id='TxDvV'><span id='TxDvV'><b id='TxDvV'><form id='TxDvV'><ins id='TxDvV'></ins><ul id='TxDvV'></ul><sub id='TxDvV'></sub></form><legend id='TxDvV'></legend><bdo id='TxDvV'><pre id='TxDvV'><center id='TxDvV'></center></pre></bdo></b><th id='TxDvV'></th></span></q></dt></tr></i><div id='TxDvV'><tfoot id='TxDvV'></tfoot><dl id='TxDvV'><fieldset id='TxDvV'></fieldset></dl></div>

  1. <legend id='TxDvV'><style id='TxDvV'><dir id='TxDvV'><q id='TxDvV'></q></dir></style></legend><tfoot id='TxDvV'></tfoot>

      • <bdo id='TxDvV'></bdo><ul id='TxDvV'></ul>
    1. <small id='TxDvV'></small><noframes id='TxDvV'>

      在水晶报表中传递参数

      passing parameters in crystal report(在水晶报表中传递参数)

        • <tfoot id='ifiKC'></tfoot>
          <i id='ifiKC'><tr id='ifiKC'><dt id='ifiKC'><q id='ifiKC'><span id='ifiKC'><b id='ifiKC'><form id='ifiKC'><ins id='ifiKC'></ins><ul id='ifiKC'></ul><sub id='ifiKC'></sub></form><legend id='ifiKC'></legend><bdo id='ifiKC'><pre id='ifiKC'><center id='ifiKC'></center></pre></bdo></b><th id='ifiKC'></th></span></q></dt></tr></i><div id='ifiKC'><tfoot id='ifiKC'></tfoot><dl id='ifiKC'><fieldset id='ifiKC'></fieldset></dl></div>
              <bdo id='ifiKC'></bdo><ul id='ifiKC'></ul>
                  <tbody id='ifiKC'></tbody>
                <legend id='ifiKC'><style id='ifiKC'><dir id='ifiKC'><q id='ifiKC'></q></dir></style></legend>
              1. <small id='ifiKC'></small><noframes id='ifiKC'>

                本文介绍了在水晶报表中传递参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在从存储过程创建水晶报告,当我传递一个参数时效果很好,但它显示错误

                I am creating crytal report from a stored procedure ,this works fine when i pass one parameter but it shows an error

                参数错误"

                当我传递两个参数时我的代码是

                when i pass two parameters my code is

                 {
                    ReportDocument reportDocument = new ReportDocument();
                    ParameterField paramField = new ParameterField();
                    ParameterFields paramFields = new ParameterFields();
                    ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();
                
                    paramField.Name = "@Dept";
                    paramDiscreteValue.Value = TextBox1.Text.ToString();
                    paramField.CurrentValues.Add(paramDiscreteValue);
                    paramFields.Add(paramField);
                
                    paramField.Name = "@Name";
                    paramDiscreteValue.Value = TextBox2.Text.ToString();
                    paramField.CurrentValues.Add(paramDiscreteValue);
                    paramFields.Add(paramField);
                
                    CrystalReportViewer1.ParameterFieldInfo = paramFields;
                    reportDocument.Load(Server.MapPath("CrystalReport.rpt"));
                    CrystalReportViewer1.ReportSource = reportDocument;
                    reportDocument.SetDatabaseLogon("sa", "sa", "OPWFMS-7KYGZ7SB", "test");
                
                }
                

                请告诉我任何更改

                推荐答案

                您需要为这两个参数创建新的 parameterField 和 value.您当前的代码添加参数,修改它(更改名称和值)并再次添加相同的对象.这应该是正确的:

                You need to create new parameterField and value for both parameters. Your current code adds parameter, modifies it (change name and value) and adds same object again. This should be correct:

                 {
                ReportDocument reportDocument = new ReportDocument();
                
                ParameterFields paramFields = new ParameterFields();
                // ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();
                
                ParameterField paramField = new ParameterField();
                ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();
                paramField.Name = "@Dept";
                paramDiscreteValue.Value = TextBox1.Text.ToString();
                paramField.CurrentValues.Add(paramDiscreteValue);
                paramFields.Add(paramField);
                
                paramField = new ParameterField(); // <-- This line is added
                paramDiscreteValue = new ParameterDiscreteValue();  // <-- This line is added
                paramField.Name = "@Name";
                paramDiscreteValue.Value = TextBox2.Text.ToString();
                paramField.CurrentValues.Add(paramDiscreteValue);
                paramFields.Add(paramField);
                
                CrystalReportViewer1.ParameterFieldInfo = paramFields;
                reportDocument.Load(Server.MapPath("CrystalReport.rpt"));
                CrystalReportViewer1.ReportSource = reportDocument;
                reportDocument.SetDatabaseLogon("sa", "sa", "OPWFMS-7KYGZ7SB", "test");
                

                }

                评论中提到的错误可能是因为代码中有两个变量paramField或paramDiscreteValue的定义.在一种 c# 方法中,您不能多次定义具有相同名称的变量.尝试上面编写的代码,如果仍然出现编译器错误,请在此处粘贴完整的错误文本.

                Error mentioned in comment is probably because there are two definitions of variable paramField or paramDiscreteValue in code. In one c# method you can't define variable with same name more than one time. Try code above as it is written and if you are still getting compiler error, please paste here full error text.

                这篇关于在水晶报表中传递参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Performance overhead of using attributes in .NET(在 .NET 中使用属性的性能开销)
                Accessing attribute info from DTE(从 DTE 访问属性信息)
                c# Hide a property in datagridview with datasource(c#使用数据源隐藏datagridview中的属性)
                Extract Display name and description Attribute from within a HTML helper(从 HTML 帮助器中提取显示名称和描述属性)
                C# Attributes and their uses(C# 属性及其用途)
                C# - Getting all enums value by attribute(C# - 按属性获取所有枚举值)
              2. <tfoot id='wzhNs'></tfoot>

                <i id='wzhNs'><tr id='wzhNs'><dt id='wzhNs'><q id='wzhNs'><span id='wzhNs'><b id='wzhNs'><form id='wzhNs'><ins id='wzhNs'></ins><ul id='wzhNs'></ul><sub id='wzhNs'></sub></form><legend id='wzhNs'></legend><bdo id='wzhNs'><pre id='wzhNs'><center id='wzhNs'></center></pre></bdo></b><th id='wzhNs'></th></span></q></dt></tr></i><div id='wzhNs'><tfoot id='wzhNs'></tfoot><dl id='wzhNs'><fieldset id='wzhNs'></fieldset></dl></div>
                    <bdo id='wzhNs'></bdo><ul id='wzhNs'></ul>
                    <legend id='wzhNs'><style id='wzhNs'><dir id='wzhNs'><q id='wzhNs'></q></dir></style></legend>

                          <tbody id='wzhNs'></tbody>

                      • <small id='wzhNs'></small><noframes id='wzhNs'>