Translate

Pages

Wednesday, 15 May 2013

passing multiple parameters in crystal reports


Passing multiple parameters in crystal reports:

hello dears,
i use your code to pass parameter to subreport like code below:

SqlConnection cnn;
            string connectionString = null;
            string sql = null;

            connectionString = "data source=.;initial catalog=Lab2;Integrated Security=yes;";
            cnn = new SqlConnection(connectionString);
            cnn.Open();
            sql = @"EXEC    [dbo].[pro_PrintReceptionReceptionInfo]" +
                            "@ReceptNum = '" + receptionNum + "'" +

                  @"EXEC    [dbo].[pro_PrintReceptionPatientTest]" +
                            "@ReceptionNum = '" + receptionNum + "'" +

                  @"EXEC    [dbo].[pro_PrintReceptionPatientInfo]" +
                            "@PatientNum = '" + patientNum + "'" +

                  @"EXEC    [dbo].[pro_PrintReceptionDepositFund]" +
                            "@ReceptNum = '" + receptionNum + "'";

            SqlDataAdapter dscmd = new SqlDataAdapter(sql, cnn);
            DataSet ds = new DataSet();
            dscmd.Fill(ds, "ReceptionInfo, PatientTest, PatientInfo, DepositFund");
            cnn.Close();

            ParameterFields pFields = new ParameterFields();

            ParameterField pf = new ParameterField();
            ParameterDiscreteValue pdv = new ParameterDiscreteValue();
            pdv.Value = int.Parse(receptionNum);
            pf.Name = "@ReceptNum";
            pf.CurrentValues.Add(pdv);

            ParameterField pf2 = new ParameterField();
            ParameterDiscreteValue pdv2 = new ParameterDiscreteValue();
            pdv2.Value = int.Parse(receptionNum);
            pf2.Name = "@ReceptionNum";
            pf2.CurrentValues.Add(pdv2);

            ParameterField pf3 = new ParameterField();
            ParameterDiscreteValue pdv3 = new ParameterDiscreteValue();
            pdv3.Value = Int64.Parse(patientNum);
            pf3.Name = "@PatientNum";
            pf3.CurrentValues.Add(pdv3);
            
            ParameterField pf4 = new ParameterField();
            ParameterDiscreteValue pdv4 = new ParameterDiscreteValue();
            pdv4.Value = int.Parse(receptionNum);
            pf4.Name = "@ReceptNum";
            pf4.CurrentValues.Add(pdv4);

            pFields.Add(pf);
            pFields.Add(pf2);
            pFields.Add(pf3);
            pFields.Add(pf4);

            crystalReportViewer1.ParameterFieldInfo = pFields;

            ReceptionPrint objRpt = new ReceptionPrint();
            objRpt.SetDataSource(ds);
            objRpt.SetParameterValue("@ReceptionNum", int.Parse(receptionNum), "ReceptionPrintTest");
            objRpt.SetParameterValue("@ReceptNum", int.Parse(receptionNum), "DepositPrintSubReport");

            crystalReportViewer1.ReportSource = objRpt;
Bottom of Form

0 comments:

Post a Comment

Thank you for your valuable comments..

 
Twitter Bird Gadget