Print Page | Close Window

add multiple values by sql in 1 parameter field

Printed From: Crystal Reports Book
Category: Crystal Reports .NET 2003
Forum Name: Writing Code
Forum Discription: .NET 2003 programming API, report integration
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=3526
Printed Date: 03 May 2024 at 4:00am


Topic: add multiple values by sql in 1 parameter field
Posted By: sarooptrivedi
Subject: add multiple values by sql in 1 parameter field
Date Posted: 25 Jun 2008 at 12:27pm

Hello sir,
thank you for reply
i have another problem regard to paramter fields

        i was design one SQL query. which return the more then one value in integer format.
how can i will pass the all values in one parameter fileds and assign value according to record

and if there are no value for record then 0 value assign for that.

here my code:
============
my method which i was design but it assign last value of sql query to all records in crystal report
----------------------------------------
  public void Sum_spay()
    {
        //// -------feetype
        ////        [1] senior ='S'
        ////        [2] multy ='M'

    ////----------------------------------------------------------------

     ParameterFields pfields = new ParameterFields();
         ParameterField pField = new ParameterField();
         ParameterDiscreteValue disVal = new ParameterDiscreteValue();
         ParameterRangeValue rVal = new ParameterRangeValue();
         sql = "SELECT  COUNT(srno)  FROM License WHERE animaltype = 'D' AND feetype = 'S'   

GROUP BY MONTH(pay_date)";
         cmd = new SqlCommand(sql, con);
         pField.ParameterFieldName = "mul";


         try
         {
             con.Open();
             dr = cmd.ExecuteReader();
             while (dr.Read())
             {
                 disVal.Value = dr[0];
                 pField.CurrentValues.Add(disVal);
                 pfields.Add(pField);
                 dc.SetParameterValue("mul", dr[0]);
                 // Response.Write("<br/>" + dr[0]);
             }
          
             CrystalReportViewer1.ParameterFieldInfo = pfields;
         }
         catch (Exception ex)
         {
             Response.Write(ex.Message);
         }
         finally
         {
             con.Close();
         }

    }


       i hope you understand my problem.
i will wait you reply
thank you
saroop
mailto:saroop.trivedi@gmail.com - saroop.trivedi@gmail.com



-------------
reply me on my mail id:saroop.trivedi@gmail.com.
crystal report help.



Print Page | Close Window