Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > Crystal Reports
|
Crystal Reports General discussion about Crystal Reports. For discussions specific to the book Professional Crystal Reports for VS.NET, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Crystal Reports section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 17th, 2004, 05:57 AM
Registered User
 
Join Date: Mar 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default CR . Net As a Web Service (Runtime Customization)

I'm new to C# .Net and Crystal Reports for .Net.

(1) I'm having problems in setting parameter fields at runtime. I used the code at the msdn
documentation but it doesn't work for me. What I want to happen is to get the value of the
parameter supplied by the user through a textbox, instead of having the parameter dialog box
prompt the user for input. But the dialog box still pops up. What wrong with my code?

Another thing is that the ParameterFieldName property (and the other properties such as
CurrentValues,MinimumValue,etc.) of the ParameterField Variable I declared is not available
for selection in the intellisense...it's replaced by set_ParameterFieldName/get_ParameterFieldName...(set_CurrentValues, etc.). How can I correct this?

(2) I published my report as a web service so I'm using the crystal report viewer in making
runtime customizations. Is there a way that I could use the report engine object model
instead, so I could have access to all the properties and methods needed to customize the
report in code?

I pasted my code below. Hope you can help me. Thanks.


using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.ReportSource;


namespace rptSamp2
{
    /// <summary>
    /// Summary description for Form1.
    /// </summary>
    public class Form1 : System.Windows.Forms.Form
    {
        private System.Windows.Forms.TextBox textBox1;
        private System.Windows.Forms.Button button1;
        private CrystalDecisions.Windows.Forms.CrystalReportViewer viewer1;
        private System.Windows.Forms.Label label1;
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.Container components = null;

        public Form1()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();
        //
        // TODO: Add any constructor code after InitializeComponent call
        //
    }

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose( bool disposing )
        {
            if( disposing )
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose( disposing );
        }

        #region Windows Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.textBox1 = new System.Windows.Forms.TextBox();
            this.button1 = new System.Windows.Forms.Button();
            this.viewer1 = new CrystalDecisions.Windows.Forms.CrystalReportViewer ();
            this.label1 = new System.Windows.Forms.Label();
            this.SuspendLayout();
            //
            // textBox1
            //
            this.textBox1.Location = new System.Drawing.Point(0, 0);
            this.textBox1.Name = "textBox1";
            this.textBox1.TabIndex = 0;
            this.textBox1.Text = "";
            //
            // button1
            //
            this.button1.Location = new System.Drawing.Point(104, 0);
            this.button1.Name = "button1";
            this.button1.TabIndex = 1;
            this.button1.Text = "button1";
            this.button1.Click += new System.EventHandler(this.button1_Click);
            //
            // viewer1
            //
            this.viewer1.ActiveViewIndex = -1;
            this.viewer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Win dows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                | System.Windows.Forms.AnchorStyles.Left)
                | System.Windows.Forms.AnchorStyles.Right)));
            this.viewer1.Location = new System.Drawing.Point(8, 32);
            this.viewer1.Name = "viewer1";
            this.viewer1.ReportSource = "C:\\Inetpub\\wwwroot\\WebService1\\CrystalReport1 .rpt";
            this.viewer1.Size = new System.Drawing.Size(272, 232);
            this.viewer1.TabIndex = 2;
            //
            // label1
            //
            this.label1.BackColor = System.Drawing.SystemColors.Desktop;
            this.label1.Location = new System.Drawing.Point(184, 0);
            this.label1.Name = "label1";
            this.label1.TabIndex = 3;
            //
            // Form1
            //
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(292, 266);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.viewer1);
            this.Controls.Add(this.button1);
            this.Controls.Add(this.textBox1);
            this.Name = "Form1";
            this.Text = "Form1";
            this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            this.ResumeLayout(false);

        }
        #endregion

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.Run(new Form1());
        }

        private void button1_Click(object sender, System.EventArgs e)
        {

            ParameterFields paramFields = new ParameterFields();
            ParameterField paramField= new ParameterField();
            ParameterDiscreteValue discValue = new ParameterDiscreteValue();
            paramField.ParameterFieldName = "Product Name";
            discValue.Value = textBox1.text;
            paramField.CurrentValues.Add (discValue);

            paramFields.Add(paramField);

            viewer1.ParameterFieldInfo = paramFields;
            viewer1.RefreshReport();

        }
    }
}


 
Old March 27th, 2004, 04:42 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

sorry but I had no time to correct ur code, could u check urself!
It worlks fine & I hope can help u too.

Code:
    public class showreps : System.Web.UI.Page
    {

        //CR Variables
        Empower.reports.foreign        crReportft;
        Empower.reports.foreign_p    crReportfb;
        ConnectionInfo crConnectionInfo;
        TableLogOnInfo crTableLogOnInfo;
        Database crDatabase;
        Tables crTables;
        ParameterFields crParameterFields;
        ParameterField crParameterField;
        ParameterValues crParameterValues;
        ParameterDiscreteValue crParameterDiscreteValue;
        protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer1;
        protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer2;

        private void Page_Load(object sender, System.EventArgs e)
        {
            string id, type;
                    id = Request.QueryString.Get("id");

                    crReportft = new Empower.reports.foreign();
                    crConnectionInfo = new ConnectionInfo();
                    crConnectionInfo.ServerName = "BORNA";
                    crConnectionInfo.DatabaseName = "NewBaz";
                    crConnectionInfo.UserID = "report";
                    crConnectionInfo.Password = "";

                    crDatabase = crReportft.Database;
                    crTables = crDatabase.Tables;

                    foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
                    {        
                        crTableLogOnInfo = crTable.LogOnInfo;
                        crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
                        crTable.ApplyLogOnInfo(crTableLogOnInfo);
                    }

                    crReportfb = new Empower.reports.foreign_p();
                    crConnectionInfo = new ConnectionInfo();
                    crConnectionInfo.ServerName = "BORNA";
                    crConnectionInfo.DatabaseName = "NewBaz";
                    crConnectionInfo.UserID = "report";
                    crConnectionInfo.Password = "";

                    crDatabase = crReportfb.Database;
                    crTables = crDatabase.Tables;

                    foreach (CrystalDecisions.CrystalReports.Engine.Table crTable in crTables)
                    {        
                        crTableLogOnInfo = crTable.LogOnInfo;
                        crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
                        crTable.ApplyLogOnInfo(crTableLogOnInfo);
                    }
                CrystalReportViewer1.ReportSource = crReportft;
                CrystalReportViewer2.ReportSource = crReportfb;
        }
    }


Always:),
Hovik Melkomian.





Similar Threads
Thread Thread Starter Forum Replies Last Post
adding web service at runtime owoade .NET Web Services 2 August 28th, 2007 02:15 AM
[Resolved] Web Service CR Refresh problem windsurfkid Crystal Reports 1 February 24th, 2007 11:29 AM
Creating a web service in ASP.NET sanjeet General .NET 1 September 14th, 2005 02:46 PM
ASP.NET COM Wrapper for Web Service ashettleroe Classic ASP Professional 0 August 12th, 2005 05:30 PM
Web Service in .Net ! augustine General .NET 2 September 15th, 2004 01:00 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.