Saturday, February 25, 2012

Can someone solve this?

Hi,
I am trying to create a local report that retrieves the data from a web
service in my business layer application but I can't figure out how to get
this dataset into my report.
Here is what I do:
I have 3 projects in my solution:
Project1.
A class library which contains a typed dataset 'myTypedDataSet'.
Project2.
A web service application with one method that returns 'myTypedDataSet'
Project3.
A windows application that contains one form and one report.
- I open my report in the designer
- Added a new datasource based on my webservice method (and 'myTypedDataSet'
showed up in the data source explorer view)
- I added the fields from 'myDataSet' to my report.
- I created a button with a click event where I call my web service that
returns an object of 'myTypedDataSet'.
Now - how can I assign this dataset to the report? I can't see anything
documented about how to do this.
Kind Regards
ThomasAhh, this is different than I thought you were asking. The thread
2005 SQL Reporting Service XML Data Source (WebService)
talks about using a web service as a source for a server based report. Your
question really has nothing to do with a web service, rather if I understand
you correctly you are wanting to use the Winform control and give it the
dataset. I have just started using this control but so far in server mode. I
know that the way the control works in local mode is you give it the dataset
and the report to use. If no one answers I suggest posting with the subject:
How do you assign dataset for Winform Control
--
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Thomas Andersson" <1qa2ws3ed4rf5tg6yh@.newsgroup.nospam> wrote in message
news:8B4AD63D-6CF0-4BCB-A3E0-0B1EDE447659@.microsoft.com...
> Hi,
> I am trying to create a local report that retrieves the data from a web
> service in my business layer application but I can't figure out how to get
> this dataset into my report.
> Here is what I do:
> I have 3 projects in my solution:
> Project1.
> A class library which contains a typed dataset 'myTypedDataSet'.
> Project2.
> A web service application with one method that returns 'myTypedDataSet'
> Project3.
> A windows application that contains one form and one report.
> - I open my report in the designer
> - Added a new datasource based on my webservice method (and
> 'myTypedDataSet'
> showed up in the data source explorer view)
> - I added the fields from 'myDataSet' to my report.
> - I created a button with a click event where I call my web service that
> returns an object of 'myTypedDataSet'.
> Now - how can I assign this dataset to the report? I can't see anything
> documented about how to do this.
> Kind Regards
> Thomas|||Hi Bruce,
> I have just started using this control but so far in server mode. I
> know that the way the control works in local mode is you give it the dataset
> and the report to use.
But how do you do this in runtime with a dataset retrieved from a web
service? This must be a very common scenarion when you use the report in
local mode.
Actually - I have implemented a solution that does this but I am not happy
with the way I do it.
On my winform button click event:
//Create an inctance of my web service proxy class and get the dataset
wsASPService myService = new wsASPService();
DataSet ds = myService.GetSalesName();
//Loop through the records of the first tables in the returned dataset and
add those
//records to my report's dataset 'dsSalesName'
//('dsSalesName' is a dataset created in this winform project)
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
dsSalesName.Tables[0].Rows.Add(ds.Tables[0].Rows[i].ItemArray[0],
ds.Tables[0].Rows[i].ItemArray[1]); //Only 2 columns in my table
reportViewer2.Refresh();
This works ok but in this solution I have created my typed dataset in my win
forms project and this is a poor design. I want to keep this dataset in a
separate project so I can share my typed dataset definitions to be used
across my solution (see my first post in this thread where I have the dataset
in a class library project).
Any ideas?
Thanks
Thomas Andersson|||I would not think you should have to copy from one dataset to another. I
would think you could just set the data source for the control to this
dataset.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Thomas Andersson" <1qa2ws3ed4rf5tg6yh@.newsgroup.nospam> wrote in message
news:D78561C5-D531-409D-93EB-48AAFBA386CD@.microsoft.com...
> Hi Bruce,
>> I have just started using this control but so far in server mode. I
>> know that the way the control works in local mode is you give it the
>> dataset
>> and the report to use.
> But how do you do this in runtime with a dataset retrieved from a web
> service? This must be a very common scenarion when you use the report in
> local mode.
> Actually - I have implemented a solution that does this but I am not happy
> with the way I do it.
> On my winform button click event:
> //Create an inctance of my web service proxy class and get the dataset
> wsASPService myService = new wsASPService();
> DataSet ds = myService.GetSalesName();
> //Loop through the records of the first tables in the returned dataset and
> add those
> //records to my report's dataset 'dsSalesName'
> //('dsSalesName' is a dataset created in this winform project)
> for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
> dsSalesName.Tables[0].Rows.Add(ds.Tables[0].Rows[i].ItemArray[0],
> ds.Tables[0].Rows[i].ItemArray[1]); //Only 2 columns in my table
> reportViewer2.Refresh();
> This works ok but in this solution I have created my typed dataset in my
> win
> forms project and this is a poor design. I want to keep this dataset in a
> separate project so I can share my typed dataset definitions to be used
> across my solution (see my first post in this thread where I have the
> dataset
> in a class library project).
> Any ideas?
> Thanks
> Thomas Andersson|||> I would not think you should have to copy from one dataset to another. I
> would think you could just set the data source for the control to this
> dataset.
I get this error message when I try to do that: "Value does not fall within
the expected range."
wsASPService myService = new wsASPService();
DataSet ds = myService.GetSalesName();
reportViewer2.LocalReport.DataSources[0] = new
Microsoft.Reporting.WinForms.ReportDataSource("dsSalesName", ds);
Is this the right way of doing it? Can you get it to work if you do a quick
sample?
Kind Regards
Thomas|||Hi Thomas,
You may use the code like below
reportViewer.LocalReport.DataSources.Add(
new ReportDataSource("DataSet1_Orders", LoadOrdersData()));
LocalReport.SubreportProcessing Event
http://msdn2.microsoft.com/en-us/library/microsoft.reporting.winforms.localr
eport.subreportprocessing.aspx
Sincerely yours,
Michael Cheng
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=====================================================This posting is provided "AS IS" with no warranties, and confers no rights.|||Got it to work. First, the datasource needs to be a table, not a dataset
(remember, datasets can have multiple tables).
Here is working code (in my case I have a dataset with a single table that
gets the data from Sybase, doesn't matter though, works the same once you
have a dataset).
Dim dsReport As New Microsoft.Reporting.WinForms.ReportDataSource()
dsReport.Value = ds.Tables(0) 'ds is your dataset
dsReport.Name = "DatasourcenameYourReport is expecting"
Me.ReportViewer1.LocalReport.DataSources.Add(dsReport)
Me.ReportViewer1.RefreshReport()
If you add it by the wrong datasource name the reportviewer will tell you.
If you are not sure of the datasource name then add a break point and use
this in immediate window:
?me.ReportViewer1.LocalReport.GetDataSourceNames(0).ToString
--
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Thomas Andersson" <1qa2ws3ed4rf5tg6yh@.newsgroup.nospam> wrote in message
news:A6EFD849-F73F-4435-A7FF-118319B16449@.microsoft.com...
>
>> I would not think you should have to copy from one dataset to another. I
>> would think you could just set the data source for the control to this
>> dataset.
> I get this error message when I try to do that: "Value does not fall
> within
> the expected range."
> wsASPService myService = new wsASPService();
> DataSet ds = myService.GetSalesName();
> reportViewer2.LocalReport.DataSources[0] = new
> Microsoft.Reporting.WinForms.ReportDataSource("dsSalesName", ds);
> Is this the right way of doing it? Can you get it to work if you do a
> quick
> sample?
> Kind Regards
> Thomas

No comments:

Post a Comment