?
Solved

ReportViewer arguments

Posted on 2010-09-22
2
Medium Priority
?
352 Views
Last Modified: 2013-12-16
I have a ReportViewer on a page, but I need to be able to set variables such as StartDate and EndDate inside the query for the report, but can seem to find any examples of how to set a query in code.

The field names will remain the same, so hopefully I dont need to re-design the report, all I really need to do is something like ReportViewer1.query = "select * from myTable where startDate < = 22/09/2010"

Any suggestions or examples would be great if anyones done anything like this before?

Thank you in advance!

Tony Cross
0
Comment
Question by:tonelm54
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 7

Expert Comment

by:DanSo1
ID: 33742393
I think it's good time for you, to choose some leading solution for reporting.
I was using many of different reporting tools but for me the best so far is FastReport.
If you can't switch, please send us more code - then somebody will help you quicker.

Regards
  Daniel

0
 
LVL 15

Accepted Solution

by:
aibusinesssolutions earned 2000 total points
ID: 33745047
If you are setting the datasource in a ASP.NET web page, then just use a SelectParameter.  In the example below, I'm using a QueryStringParameter.  
<rsweb:ReportViewer ID="ReportViewer1" runat="server" ExportContentDisposition="AlwaysInline">
            <LocalReport EnableExternalImages="True" ReportPath="Design.rdlc">
                <DataSources>
                    <rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="DataSet1_tblContracts" />
                </DataSources>
            </LocalReport>
        </rsweb:ReportViewer>
        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OldValuesParameterFormatString="original_{0}"
            SelectMethod="GetData" TypeName="DataSet1TableAdapters.tblContractsTableAdapter">
            <SelectParameters>
                <asp:QueryStringParameter Name="contactID" QueryStringField="id" Type="Int32" />
            </SelectParameters>
        </asp:ObjectDataSource> 

Open in new window

0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question