none
adding multiple parameters .rdlc report RRS feed

  • Question

  • Hello There,

                  I have created this procedure with parameters it worked well when i did it on rdl report but the problem is i should make it on client machines that's why i created .rdlc report with 2 datetime   as the user will select the date from datetimepicker1 for example(1/04/2010) to datetimepicker2 (30/04/2010) and selects his name from a combobox

     combobox1 and displays  employee's names

     

    SqlConnection c = new SqlConnection("Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=fingertec;Data Source=npalx39");

     

    string sql = "select Distinct name1 from employee where StoreID=13";

    comboBox1.Items.Add(sql);

    the problem is i can't add the 2 datetime (from and to) as parameters

    i aDDED them on the stored procedure i made im sql as below

    create

    procedure [dbo].[ballydata]

    (

    @name1 varchar(20)=NULL,@datetime1 datetime=null,@datetime2 datetime=null)

    as

    begin

    select

    distinct a1.enrollno,e.name1,a2.datetime1 as 'Datetime In',a2.check1 as [Check In],a1.datetime1 as 'Datetime Out',a1.check2 as [Check Out],

    datediff

    (second,a2.datetime1,a1.datetime1)/3600 as 'Hours' , datediff(second,a2.datetime1,a1.datetime1)%3600/60 as 'Minutes'

     

    from attendance2 as a1 inner join

    employee

    as e

    on

    a1

    .EnrollNo=e.EnrollNo

    inner

    join attendance2 as a2

    on

    a2

    .EnrollNo=e.EnrollNo

    where

    a1

    .EnrollNo=a2.EnrollNo and e.name1=@name1 and a1.datetime1>=@datetime1 and a1.datetime1 <=@datetime2 and a2.Check1 = 'Check In' AND a1.check2 = 'Check Out'

    AND

    a1.datetime1 = (SELECT Min(datetime1) FROM attendance2 WHERE EnrollNo = a2.EnrollNo AND datetime1 >a2.datetime1)

    group

    by a1.enrollno,a2.datetime1,a1.datetime1,a2.check1,a1.check2,e.name1

    order

    by a1.EnrollNo,a1.datetime1,a2.datetime1

    end

    i can't add them on the .rdlc reportviewer

    i used this but it's not working

     

    SqlCommand cmd = new SqlCommand("ballydata", c);

    cmd.CommandType =

    CommandType.StoredProcedure;

    cmd.Parameters.Add("@name1",SqlDbType.VarChar,3);

     

    cmd.Parameters.Add("@datetime1", SqlDbType.DateTime);

     

     

     

    reportViewer1.RefreshReport();

    would anyone please,help me?.

    Thanks,

    Tuesday, May 4, 2010 10:02 AM

All replies

  • Hi emmy_23, not sure what you mean by "add them on the .rdlc report". The report parameters in your .rdlc report will not map to parameters in your stored procedures.

    Question: Does your report run correctly if you hardcode the values of @datetime1 and @datetime2 into your stored procedure (i.e. transform it into a parameter-less query)?


    Cephas Lin This posting is provided "AS IS" with no warranties.
    Tuesday, May 4, 2010 2:11 PM
    Moderator