Solved

ReportViewer arguments

Posted on 2010-09-22
2
347 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 500 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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…

756 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