Click here to Skip to main content
12,510,836 members (57,259 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#
Hi,
I pass the parameters using code in c# but the "Parameter Value Window" is open every time I open the report...please help me in that..here is my code
void loadordinfo()
       {
     // here the query code.............
           MySqlDataAdapter adpat = new MySqlDataAdapter(sltinfoord, conn);
           ordset = new DataSet();
           adpat.Fill(ordset, "orderbill");
           ordtb = new DataTable();
           adpat.Fill(ordtb);
           objRpt = new CrystalReport4();
           objRpt.SetDataSource(ordset);
       }
 
       private void pictureBox1_Click(object sender, EventArgs e)
       {
           try
           {
 
               crystalReportViewer1.ReportSource = objRpt;
           }
           catch (FormatException oleEx)
           {
               MessageBox.Show(oleEx.Message);
           }
           catch (Exception Ex)
           {
               MessageBox.Show(Ex.Message);
           }
       }
       private void OrdersBillReport_FormClosing(object sender, FormClosingEventArgs e)
       {
           objRpt.Dispose();
           objRpt.Close();
       }
 
       private void OrdersBillReport_Load(object sender, EventArgs e)
       {
           conn = new MySqlConnection(path.p);
           CargoPrivateFontCollection();
           CargoEtiqueta(font);
           loadordinfo();
           oo = new orgnization();
           oo.orgnizationinfo();
 
           crystalReportViewer1.ReuseParameterValuesOnRefresh = false;
           objRpt.SetParameterValue("n", oo.organame.ToString());
       }
   }
Posted 21-Feb-13 9:52am
jumah644
Updated 21-Feb-13 10:43am
v2

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Use this to pass value to your parameter in crystal report


Using CrystalDecisions.Shared; //add this namespace;

 
ParameterFields paramfields = new ParameterFields(); //collection of parameters
ParameterField paramfield = new ParameterField(); //your parameter
ParameterDiscreteValue dsvalue = new ParameterDiscretValue(); // holder of your the value for the parameter

 
paramfield.Name = "Nameofparameter in crystal report"
dsvalue.Value = "the value you want to pass";
paramfield.CurrentValue.Add(dsvalue); //this assign the value to your parameter
paramfields.Add(paramfield); //add the parameterfield to the parameterfields collection

crystalReportViewer1.ParameterFieldInfo = paramfields; //this will assign the parameter fields to the report loaded in crystalreportviewer1

loadordinfo(); // call this method here

hope it helps.

you can also try this 1.
private void OrdersBillReport_Load(object sender, EventArgs e)
{
    conn = new MySqlConnection(path.p);
    CargoPrivateFontCollection();
    CargoEtiqueta(font);
 
    oo = new orgnization();
    oo.orgnizationinfo();
 
    crystalReportViewer1.ReuseParameterValuesOnRefresh = false;
    objRpt.SetParameterValue("n", oo.organame.ToString());
 
    loadordinfo();
 
}
  Permalink  
Comments
jumah 22-Feb-13 2:18am
   
Thank you..the first answer solved the problem many thanks again
Green And Blue 22-Feb-13 3:30am
   
you're welcome

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160929.1 | Last Updated 21 Feb 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100