Pass parameter for stored procedure in crystal report
I have stored procedure like:
CREATE PROCEDURE dbo.item_type (@LC_No nvarchar(250)) AS
select (Type_yarn + Count_yarn) as Yarn_Type from LC_Statement_Yarn_View where LC_No=@LC_No
GO
I want to pass parameter value to stored procedure. Part of my coding is like that:
SqlCommand comm01 = new SqlCommand("item_type", conn);
comm01.CommandType = CommandType.StoredProcedure;
//comm01.Parameters.Add(new SqlParameter("@LC_No", yarn_LC));
ParameterFields paramFields = new ParameterFields();
ParameterField param_yarn_LC = new ParameterField();
param_yarn_LC.ParameterFieldName = "@LC_No"; //year is Crystal Report Parameter name.
ParameterDiscreteValue dis_yarn_LC = new ParameterDiscreteValue();
dis_yarn_LC.Value = yarn_LC;//Import_Register.Program.Bank_name.Bank01;
param_yarn_LC.CurrentValues.Add(dis_yarn_LC);
paramFields.Add(param_yarn_LC);
crystalReportViewer1.ParameterFieldInfo = paramFields;
--------------------------------
But it is not working.
Parameter is not taken by crystal report. Is there any process to pass parameter to stored procedure?