Visual Studio 2010のCrystalレポートにパラメーターを渡す方法は?それらは無視されているようです

StackOverflow https://stackoverflow.com/questions/4205541

質問

これはVisual Studio 2008で正しく機能していましたが、Visual Studio 2010とVisual Studio 2010のCrystal Reportsに切り替えているため、私の合格したパラメーターは無視されます。

彼らはレポートに表示され、選択式に関しては無視されました!レポートを作成し、パラメーターを渡すための私のコードです。

 private void Prepare()
    {
        var reportDocument = new ReportDocument();

        string reportPath = string.Format(
            "{0}\\{1}",
            Globals.FormPath,
            this.FormTemplate.Filename);

        reportDocument.Load(reportPath);

        ParameterDiscreteValue parameter;

        foreach (var control in this.FormTemplateFieldControls)
        {
            switch (control.FormTemplateField.DataType)
            {
                case FormFieldDataType.Date:
                    this.AddParameterForDateTime(
                        reportDocument,
                        control.FormTemplateField.Name,
                        (DateTime)control.EditValue);
                    break;
                case FormFieldDataType.DateTime:
                    this.AddParameterForDateTime(
                        reportDocument,
                        control.FormTemplateField.Name,
                        (DateTime)control.EditValue);
                    break;
                case FormFieldDataType.Time:
                    this.AddParameterForDateTime(
                        reportDocument,
                        control.FormTemplateField.Name,
                        (DateTime)control.EditValue);
                    break;
                case FormFieldDataType.Guid:
                    this.AddParameterForGuid(
                        reportDocument,
                        control.FormTemplateField.Name,
                        (Guid)control.EditValue);
                    break;
                default:
                    this.AddParameterForString(
                        reportDocument,
                        control.FormTemplateField.Name,
                        control.EditValue.ToString());
                    break;
            }
        }

        this.SetConnectionInfo(reportDocument);

        var frm = new FormViewer();

        frm.Report = reportDocument;

        frm.ShowDialog();

        frm.Dispose();

        this.Close();
    }

デザイナーからレポートを実行すると、うまく機能します。私のレポートに表示されているときに、パラメーターが渡されていることがわかります。

alt text

ストアドプロシージャから実行される私のレポートでは、パラメーターは正常に渡されるように見えます。これは、すべてのテーブルで構成されるものだけです。

それが価値があることのために、ここに私の選択式があります:

 {employee.HireDate} >= {?StartDate} And {employee.HireDate} <= {?EndDate}
役に立ちましたか?

解決

これは、Visual Studio 2010のCrystal Reportsの最新バージョンで解決されました。

他のヒント

あなたが「彼らは通過しない」と言うとき、何が合格されますか?彼らは空白ですか?

パラメーター自体を確認し、笑顔で別の名前を付けて、特にユニークなものを与えてみてください。他のレポート設定やパラメーターの定義方法で間抜けなことが起こっている可能性があります。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top