locked
The report parameter ‘datetime1’ has a DefaultValue or a ValidValue that depends on the report parameter “datetime1”. Forward dependencies are not valid.

    Question

  • Hello There,

                    i'm have .rdlc report which have dataset(fingertecDataSet) from stored procedure

    (reportB) as below:

    create

     procedure [dbo].[reportB]

    @datetime1

    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

    inner

    join store as st

    on

    a2

    .StoreID=st.StoreID

    where

    a2

    .StoreID=13 and a1.enrollno=a2.EnrollNo and

    a1

    .datetime1>='2010-05-01' and a1.datetime1 <='2010-06-02' and a2.Check1 = 'Check In' AND a1.check2 = 'Check Out'

    AND

    a1.datetime1 = (SELECT distinct 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'm having datetime1 as a parameter in the report but i cant know how to make it in .rdlc report.it worked on the report server and it was easy to add the parameters without writing much code.

    I clicked on report then report parameters tab then i added datetime1 and i added the default value as =Parameters!datetime1.Value.unfortunatelly it gaves me this error

     The report parameter ‘datetime1’ has a DefaultValue or a ValidValue that depends on the report parameter “datetime1”. Forward dependencies are not valid. 

    ---------------------------

    this is code i wrote in the page load :i want the parameter to be visible in a combobox or in datetimepicker.i tried here to make it as combobox but it didnt work.

     ReportParameter[] Params = new ReportParameter[1];

    Params[0] =

    new ReportParameter("from", comboBox1.SelectedItem.ToString());

    reportViewer1.LocalReport.SetParameters(Params);

     

    reportViewer1.ProcessingMode = ProcessingMode.Local;

    reportViewer1.LocalReport.ReportEmbeddedResource = "Quebramar1.queb.rdlc";

    reportViewer1.LocalReport.DataSources.Add(

     

    new Microsoft.Reporting.WinForms.ReportDataSource(

     

    "fingertecDataSet_reportB"));

     

    reportViewer1.ServerReport.SetParameters(Params);

    reportViewer1.RefreshReport();

     

    thanks,

    Monday, June 07, 2010 8:19 AM

Answers

  • There are a lot of examples out there.
    I arbitrarily picked the following one where you also can download the code:

    Building Report-enabled Applications with the New ReportViewer Controls:
    http://www.devx.com/dotnet/Article/30424/0/page/5

    Hope this helps,

    Marcel

    • Marked as answer by emmy_23 Tuesday, June 08, 2010 11:21 AM
    Tuesday, June 08, 2010 10:27 AM

All replies

  • Hi Emmy,

    It's really hard to read through your post (please use Insert Code Block from the editor's toolbox when you post code).

    What I can see is that you're not decided on whether to use the report instance locally or remotely (s. reportViewer1.LocalReport vs. reportViewer1.ServerReport in your code).

    From the documentation: The LocalReport object does not have the ability to execute queries or fetch data; instead data must be supplied to it as instances of ADO.NET DataTables or as a collection of business objects. [...] The LocalReport object supports report parameters, but does not support query parameters.

    Marcel

    Monday, June 07, 2010 10:26 AM
  • i'll work on localreport..because the pc's which i'll deploy the program on it won't have reporting service installed on it.this is the stored procedure with datetiem1 as an input

    ALTER

    procedure [dbo].[reportB]

    @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

    inner

    join store as st

    on

    a2

    .StoreID=st.StoreID

    where

    a2

    .StoreID=13 and a1.enrollno=a2.EnrollNo and

    a1

    .datetime1>='2010-05-01' and a1.datetime1 <='2010-06-01' and a2.Check1 = 'Check In' AND a1.check2 = 'Check Out'

    AND

    a1.datetime1 = (SELECT distinct 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

    if the query parameter wont work as you say on .rdlc then is that possile to add combobox or datetimepicker to make te user select a specific date then from:(datetime1) and TO:(datetime2).

    i dont know how to make this ..as i said i already tried make it on report server and it worked fine with me.

    this is code i wrote in the page load :i want the parameter to be visible in a combobox or in datetimepicker.i tried here to make it as combobox but it didnt work.

    ReportParameter[] Params = new ReportParameter[1]; 
    Params[0] =new ReportParameter("from", comboBox1.SelectedItem.ToString());
    reportViewer1.LocalReport.SetParameters(Params);
    reportViewer1.ProcessingMode = ProcessingMode.Local;
    
    reportViewer1.LocalReport.ReportEmbeddedResource = "Quebramar1.queb.rdlc"; 
    
    reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("fingertecDataSet_reportB")); 
    reportViewer1.ServerReport.SetParameters(Params); 
    reportViewer1.RefreshReport();
    

    plzz,tell me what to do.

    Monday, June 07, 2010 11:07 AM
  • You haven't corrected your code yet. Get rid of the line setting the parameters for the ServerReport. Also ensure that your embedded report doesn't use server mode. Then look into the overloads for the constructor of ReportDataSource. What you must do is simply fill a DataTable from your stored procedure and pass it as a ReportDataSource to the LocalReport.
    Monday, June 07, 2010 1:45 PM
  • Marcel,

    Thx for replying me..

     

    but isn't the above code is enough excluding the parameter..can i see a small example..

    i mean i displayed the report from dataset ...i dont know why u say i should fill it using the datatable.

    i will add two textboxes filling the date (from) and (to) on them..but i dont know how populate the date from the stored procedure or datatable.

    i'm sorry but i'm still a beginner in ADO.net.

    can u suggest me a link or a steps i would follow?

    Thanks Alot

    Tuesday, June 08, 2010 7:35 AM
  • There are a lot of examples out there.
    I arbitrarily picked the following one where you also can download the code:

    Building Report-enabled Applications with the New ReportViewer Controls:
    http://www.devx.com/dotnet/Article/30424/0/page/5

    Hope this helps,

    Marcel

    • Marked as answer by emmy_23 Tuesday, June 08, 2010 11:21 AM
    Tuesday, June 08, 2010 10:27 AM
  • thx alot marcel

    i'll implement it.

    Tuesday, June 08, 2010 11:19 AM
  • i tried to read and implement this application..unfortunatelly i dont understand why he's using entities in this part of calling getcustomers and i'm asking if there is other way to call the parameters on the report.

    private ReportDataSource GetCustomers(ReportParameter customers)
        {
          string criteria = null;
          // Get the application dataset. In real life, the dataset will typically come from the business logic layer
          
          //Entities.CustomerOrdersTableAdapters.CustomerOrdersTableAdapter adapter = new Entities.CustomerOrdersTableAdapters.CustomerOrdersTableAdapter();
          // Get the selected customer ids
    
          foreach (String value in customers.Values)
          {
            criteria+= "," + value;
          }
          criteria = criteria.Remove(0, 1); // remove trailing ","
          MyCustomerAdapter adapter = new MyCustomerAdapter(criteria);
          CustomerOrders.CustomerOrdersDataTable table = adapter.GetData();
          // One dataset for this report required
          return new ReportDataSource("dsOrders", table);
        }

    Wednesday, June 09, 2010 10:57 AM
  • Don't get stuck into implementation details. The method you posted above simply takes a report parameter and passes it to a custom data adapter to pre-filter the data accordingly. You allways have two options when dealing with local reports: 1) Pre-filter the data by querying the datasource and associate it with the report, or 2) Return all of the data from the datasource and filter locally by setting report parameters. Take a look here:

    http://www.gotreportviewer.com/localmodeparameters/index.html

    Wednesday, June 09, 2010 3:09 PM