Hi there! ive looked over the forums and other websites that you referred but i dont have any luck for reports. i created a page that has simple data-entry, aside from that, i do want to have a printable report on what are the items i have added this day. i am using a report designer (rdlc) and a report viewer, which is in a aspx page. ive explored how it works for a simple select statement but i want to know how it will work for parameter passing. a referral for a tutorial website for the report viewer and report designer is very much appreciated. or if you want to share your knowledge about it, that will be a great help. thanks.
![]() |
0 |
![]() |
![]() |
0 |
![]() |
For stedi_girl:
Just add the condition, e.g where parameter = ? (this is for mysql format)
And then add a select parameter to the objectdatasource
For devarajdotnet:
You have to add dataset to populate your report...then just drag the items from the datatable to your report (*.rdlc)
![]() |
0 |
![]() |
The reportviewer is a little difficult to get used to. AS for the parameters - you have to explicitely create the parameter object - fill it with parameter values ( a name-value pair) and then add it to the report.
As for the report missing a dataset - you need to add a dataset.
In local mode ( without a report server ... using rdlc) you have to provide all the data and parameters to the report - it can't do anything other than digest what you pass it
Here's a snippet on how I pass a parameter ( remember to add the parameter to the rdlc)
Dim MyParameters As ReportParameter = New ReportParameter("TechName", technicians.SelectedItem.ToString())
Me.ReportViewer1.LocalReport.SetParameters(New ReportParameter() {MyParameters})
I do this on page_load ( but I'm not sure if thats the best place )
the best reference I have found is http://gotreportviewer.com
Hope That Helps
All that wander, are not lost...
What were we talkin bout
![]() |
0 |
![]() |
thanks for the explanation uncleb, but believe me, you dont need any coding to add the parameter...my code behind is empty...thats the power of .net 2.0
At the Table Adapter Configuration Wizard, just do like this eg "SELECT * FROM tbl_something
WHERE condition = ?"...like I mention before the '?' is for mysql format, i'm not sure if it works for other database.Use the ObjectDataSource to configure you parameter...use the select parameter and select a parameter source/ID eg: dropdownlist...it's that simple
The parameter list (filter,delete,insert) in the ObjectDataSource will do everything for you without any extra coding...
By the way, I'm trying to figure out if I can use multiple report (*.rdlc) in one report viewer..this one I think need some extra coding...if anyone could give me any idea, it would be nice...
![]() |
0 |
![]() |
thats for specifying a parameter for the sql
the post is about specifying a report parameter - 2 different things.
Besides the data, you might want to pass other parameters to the report.
When designing a report - goto Report Menu - First Item - Report Parameter.
Hope That Helps
All that wander, are not lost...
What were we talkin bout
![]() |
0 |
![]() |
hmm..maybe I am confuse...
well...if you add a parameter for the sql....and the sql source is used by your report...doesnt it passses the parameter for the report also?
May I know what other parameter (besides data) that you mention?
![]() |
0 |
![]() |
From the Help...
Use the Report Parameters dialog box to define parameters for a report that is processed in local mode. You can define parameters to support conditional formatting or to use in expressions or code. You cannot use the Report Parameters dialog box to map report parameters to query parameters or use them in data source filters. In local processing mode, all data processing is handled independently of report processing. If you want to pass report parameters to a query or data source filter, you must do so in application code.
I use it for a report that pulls service calls assigned to technicians. I pass the TechnicianID as a SQL parameter ( used to select only calls for that tech) But I also pass the technicians name as a report parameter - and i use it in the Title.
=Parameters!TechName.Value ( in a label )
.
Hope That Helps
All that wander, are not lost...
What were we talkin bout
![]() |
0 |
![]() |
hi hi,
i'm using DataAdapter Configuration Wizard to specify my dataset and my report is in rdlc.
how can i pass my parameter value through url ?
i'm not sure how to declare my report parameter. i have added the parameters in rdlc and also in select parameter in ObjectDataSource.
i'm stuck in my coding.
ReportParameter[] parameters = new ReportParameter[2];
parameters[0] = new ReportParameter("property", ????)
???? supposedly stores the parameter value, if i'm not mistaken.
PLease help...
thanks!
![]() |
0 |
![]() |
you don't actually pass the parameter using url - that would be for a report server, not a local report.
do you use the parameter in the report - or is it just o select the data. - There is a difference.
lets say I wanted a report of all slaesman in a particular state. I could make a SQL that looks something like this
"SELECT SalesmanName, SalesmanPhone from SalesMan WHERE SalesManState='CA'"
I could use this as the data for a report as is.
But what If I wanted to have a Title on the report that says something like "Salesman for State of CA"
the CA part is not one of the fields returned, and if it was ( by adding it to the SQL select part) it would be repeated for each salesman.
You can't use a field in a non-repeating section of the report ( like the header - where I am setting the Title)
So in order to be able to specify the CA for the title, I need to pass it as a parameter to the report.
EVEN THOUGH THE DATASOURCE HAS THE PARAMETER AS PART OF THE SQL
To do this, you add a parameter to the report using the parameter dialog - call it something like TitleState.
then in code you would do something like ( lets assume that you can pick the state from a dropdown on your page)
Dim MyParameters As ReportParameter = New ReportParameter("TitleState", States.SelectedItem.ToString())
Me.ReportViewer1.LocalReport.SetParameters(New ReportParameter() {MyParameters})the name of the param in the report, and the name of the param you add to the report at runtime have to match (TitleState)
Not sure how to pass more than 1 parameter, but it seems like it is an array the way it is declared.
be sure to check out http://gotreportviewer.com/
Hope That Helps
All that wander, are not lost...
What were we talkin bout
![]() |
0 |
![]() |
thanks uncleb,
does that mean i can never access a local report through url ? hmm...
i found out i can obtain the parameter from url by using Request.QueryString
{
ReportParameter[] parameters = new ReportParameter[2]; parameters[0] = new ReportParameter("property", this.Request.QueryString[0]); parameters[1] = new ReportParameter("account", this.Request.QueryString[1]); ReportViewer1.LocalReport.SetParameters(parameters); ReportViewer1.LocalReport.Refresh(); } but i get this error when previewing: please help..
![]() |
0 |
![]() |
oh... btw, the parameters are to filter the dataset.....
![]() |
0 |
![]() |
i need to use url to access the report. the user will open an account information form and by clicking a button , the report will be shown in another window. it's a web app.
ops... i realized i'm using TableAdapter, not DataAdapter as mentioned. sorry.
thanks.
![]() |
0 |
![]() |
you need to specify what you want to do. if you need parameters to filter your dataset - then pass the parameter using querystring ( or any other method - session, page variable, previospagevalue,hidde field,etc...) to page that builds the dataset - you will use the parameters on a SQL query to build the dataset . You then set the report's datasource to this dataset. The report will then take this dataset and display it using the report definition you created. The reportviewer can not do any database stuff - you must pass all the data that the report needs at one time.
All of the above is about passing parameter to be used in the "WHERE" clause of a SQL command.
The other type of parameter is like I described in other post - used in the report - not to filter data.
does that mean i can never access a local report through urlyou don't specify the report in the url like with a reportserver - you specify an aspx page that has a localreport (local meaning embedded in a an aspx page and not served by a reportserver)
Hope That Helps
All that wander, are not lost...
What were we talkin bout
![]() |
0 |
![]() |
thanks uncleb!
got it working...
![]() |
0 |
![]() |
I'm having trouble passing parameters to a local report from a textbox. Please help and post me that working code you used and i can modify to suite my needs.basketcase:
thanks uncleb!
got it working...
Thanks.
--------------------------------------------------
No Project Too Eazy.
--------------------------------------------------
![]() |
0 |
![]() |
Hi,
I'm trying to pass a variable used in my code as a parameter to display in the report , it says that ReportParameter is unknown identifier. Can you guide me ?
my code is like this ...
----------------------------------------------
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
double m;
m=3;
ReportParameter P = new ReportParameter;
P= new ReportParameter("foo", m);
this->reportViewer1->LocalReport->SetParameters(P) ;
}.--------------------------------------------------------------------------------------------------------------------------------------------------------------
errors are
c:\documents and settings\rk\my documents\visual studio 2008\projects\reportviewertesting\reportviewertesting\Form1.h(125) : error C2065: 'ReportParameter' : undeclared identifier
c:\documents and settings\rk\my documents\visual studio 2008\projects\reportviewertesting\reportviewertesting\Form1.h(125) : error C2146: syntax error : missing ';' before identifier 'P'
c:\documents and settings\rk\my documents\visual studio 2008\projects\reportviewertesting\reportviewertesting\Form1.h(125) : error C2065: 'P' : undeclared identifier
c:\documents and settings\rk\my documents\visual studio 2008\projects\reportviewertesting\reportviewertesting\Form1.h(125) : error C2061: syntax error : identifier 'ReportParameter'
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
RK
![]() |
0 |
![]() |