Click here to Skip to main content
16,009,318 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
C#
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
Updated 21-Feb-13 10:43am
v2

1 solution

Use this to pass value to your parameter in crystal report


C#
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.
C#
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();

}
 
Share this answer
 
Comments
jumah 22-Feb-13 2:18am    
Thank you..the first answer solved the problem many thanks again
ZaneArellano 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900