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 July 11th, 2005, 04:26 AM
Registered User
 
Join Date: Jul 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Roopedog
Default Passing Parameters to a Report.

I am trying to create a report based on a paramter that is taken from a text box. I have tried many things and i either get a enter parameter value dialog box or error messages surrounding the get statement. Could somebody please look at my code and tell me where it is incorrect. It would be much appreciated.

public void Form2_Load(object sender, System.EventArgs e)
{


            CrystalDecisions.CrystalReports.Engine.Database crDatabase;

            ReportDocument oRpt = new ReportDocument();
            oRpt.Load("C:\\Documents and Settings\\andy\\Desktop\\Colin\\Visual Studio Projects\\PlayerList\\CrystalReport1.rpt");
            crDatabase = oRpt.Database;

            CrystalReportViewer1.ReportSource = oRpt;


                        setReportParameters();

        }

        public int nTournament_ID
        {
            get{return nTournament_ID;}
            set{nTournament_ID = int.Parse(((Form1)MyParentForm).textBox1.Text.ToSt ring());}


        }

        public void setReportParameters()
        {



            ParameterFields paramFields = new ParameterFields();

            ParameterField pfTournament_ID = new ParameterField();

            ParameterDiscreteValue dcTournament_ID = new ParameterDiscreteValue();

            pfTournament_ID.ParameterFieldName = "@Tournament_ID";

            dcTournament_ID.Value = nTournament_ID;

            pfTournament_ID.CurrentValues.Add(dcTournament_ID) ;

            paramFields.Add(pfTournament_ID);

            CrystalReportViewer1.ParameterFieldInfo = paramFields;
        }

    }



 
Old July 11th, 2005, 03:54 PM
Registered User
 
Join Date: Jul 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Roopedog,

I am having the same problem. I bought the Crystal Reports book from David McAmislast month. Unfortuneately there is some bug in C# with this interface or something we are not seeing. I tried the example in his book (under VB) and you can easily get the parameter from a Text Box. He (David M) even says in the book to not drag the Parameter Field onto your report and the dialog will not appear. This is false, as I have tried that trick. My only parameter use is in a record selection formula. Then, his example shows the parameter dragged onto the Title section and it still does not bring up the dialog. I created the ParameterField ParameterFields and myDiscreteValue objects and still have the same dialog pop up and ask for the parameter. If I follow his rules in the book, or do exactly what he did in c#, I ALWAYS get the parameter dialog. If I do the example in VB, it seems to behave as he has stated in the book. Because its C#, I cannot get to the embedded code that is generated to try and bypass this defualt parameter dialog. Tonight, I am going to try and install VS 2005 Beta to see if the problem exists. Also, I will try VB isntead of c# (hate those Dim's! but I have to do it) as this is the only time I can get rid of that "automated" dialog, following the VB example in the book.

DO any of the moniotors know what is going on here? I am using VB 2003, with Crystal Reports registered from VS.NET. Is there an upgrade that will fix this? DO I just need to try VB instead? IT seems that maybe the Crystal Reports/Visual Studio interface is more buggy in c#. The example works in VB, but my entire applicaiton has been developed under c#.
 
Old July 12th, 2005, 05:13 AM
Registered User
 
Join Date: Jul 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Roopedog
Default

Could you let me know what happens please eric. It would be a complete waste of our time if we had to re-write the applications in VB. There must be some way of overcoming this problem.

Roopedog

 
Old July 14th, 2005, 09:30 AM
nfg nfg is offline
Registered User
 
Join Date: Jul 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to nfg
Default

In VS.NET 2003 I simply use the following:

ReportForm reportForm = new ReportForm();
reports.MerchantSalesByMonth doc = new reports.MerchantSalesByMonth();

doc.SetParameterValue("merchantId", form.Merchant.Id.ToString());
doc.SetParameterValue("dateStart", form.DateStart.ToString());
doc.SetParameterValue("dateEnd", form.DateEnd.ToString());
doc.SetDatabaseLogon("xxx", "xxxx");

Is this what you're after?

 
Old July 25th, 2005, 02:17 AM
Registered User
 
Join Date: Jul 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm quit new to this and just stumbled on this post looking for something else, but i'm missing the "enableparameterprompting" method, set it to false to disable the parameter prompt.
Maybe thats what you are looking for?







Similar Threads
Thread Thread Starter Forum Replies Last Post
passing parameters to Access Report murtazasif Access VBA 2 November 6th, 2007 12:32 PM
Passing parameters from main report to subreport Swati_Jain Crystal Reports 0 May 24th, 2006 09:04 AM
Problem passing parameters in Crystal Report. joydip_kanjilal Crystal Reports 0 October 8th, 2004 01:47 AM
passing parameters at runtime using crystal report anilkumar Crystal Reports 2 January 3rd, 2004 01:35 AM
Best practice of Passing Parameters for a report? segeller Crystal Reports 1 August 29th, 2003 01:08 AM





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