Passing Parameter in ...
-
Could anyone help me how to pass parameter in crystal report using c#.net? I'm new to this.I need a sample code Thanks In Advance REGARDS,
s_mostafa_h
-
In Form1 I've a checkbox . I created a parameter in crystal report . this is my code : in btnReport_Click :
{
string strQuery = "SELECT Name FROM MyTable";
sqlconn.Open();
daAdapter = new SqlDataAdapter(strQuery, sqlconn);
SqlCommandBuilder scb = new SqlCommandBuilder(daAdapter);
da.Fill(DatatSet1.MyTable);
//Definitions
ParameterField paramfield = new ParameterField();
ParameterFields paramfields = new ParameterFields();
ParameterDiscreteValue discreteval = new ParameterDiscreteValue();
//setting
paramfield.Name = "Name";
discreteval.Value = DataSet1.MyTable.Columns[0];
paramfield.CurrentValues.Add(discreteval);
paramfields.Add(paramfield);
crystalReportViewer1.ParameterFieldInfo = paramfields;
crystalReportViewer1.ReportSource = crystalreport1;
sqlconn.Close();
}I want to take a report from all of records' Name field of the Table When The user checked "CheckBox1" Control . I have an Error in this part : discreteval.Value = DataSet1.MyTable.Columns[0]; with this message : Value does not fall within the expected range. Please Help Me ! Regrds ,
s_mostafa_h
-
In Form1 I've a checkbox . I created a parameter in crystal report . this is my code : in btnReport_Click :
{
string strQuery = "SELECT Name FROM MyTable";
sqlconn.Open();
daAdapter = new SqlDataAdapter(strQuery, sqlconn);
SqlCommandBuilder scb = new SqlCommandBuilder(daAdapter);
da.Fill(DatatSet1.MyTable);
//Definitions
ParameterField paramfield = new ParameterField();
ParameterFields paramfields = new ParameterFields();
ParameterDiscreteValue discreteval = new ParameterDiscreteValue();
//setting
paramfield.Name = "Name";
discreteval.Value = DataSet1.MyTable.Columns[0];
paramfield.CurrentValues.Add(discreteval);
paramfields.Add(paramfield);
crystalReportViewer1.ParameterFieldInfo = paramfields;
crystalReportViewer1.ReportSource = crystalreport1;
sqlconn.Close();
}I want to take a report from all of records' Name field of the Table When The user checked "CheckBox1" Control . I have an Error in this part : discreteval.Value = DataSet1.MyTable.Columns[0]; with this message : Value does not fall within the expected range. Please Help Me ! Regrds ,
s_mostafa_h
-
copy this, and paste in VS Help address box: ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/crystlmn/html/crtsktutorialsrdparametersdiscrete.htm this is Tutorial: Reading and Setting Discrete Parameters
-
it didn't help me . in any case , when the user checked the checkbox contrlol , I want to dislpaly all of the specied field record (for e.g. "Name"), How can i do in this section :
**discreteval.Value =???**
thankss_mostafa_h
-
ParameterDiscreteValue.Value Property Gets or sets the value of the parameter. This can be a string, number, currency, Boolean or date. -- try
discreteval.Value = "special_name";
-
this shows only one record of field that we specified . but I Want to show all record this field column . my field is "Name" in the table . regards,
s_mostafa_h
you can build all names in to a string, like this: name1,name2,name3 then split it in crystal report formula editor? I am not sure which manner you used in crystal report. if you can't split it. I have no idea. may be you need contact crystal report support to solve your problem?