Use WebService to dynamically generate dataset and bind it to reporting services

Source: Internet
Author: User

After reading vs2005 + sql2005 reporting service dynamic binding report (Web) of Fei. Lu of carlwave, I think his solution may be feasible, but it is not very good. So I found some information and found that the dataset dynamically generated through WebService can be bound to reporting services, which satisfies the operability of dataset, that is, you can program and operate dataset in WebService.

My steps are as follows:
1. First create a webserivce, and then write a web method:

[Webmethod]
Public Xmldatadocument getdatasource ()
{
String Strcon;

Dataset DS =   New Dataset ();
Xmldatadocument xmldatadoc;

Strcon =   " Your connection string " ;

String Selecttext =   " Your select string " ;

Sqldataadapter dataadapter =   New Sqldataadapter (selecttext, strcon );


Try {
Dataadapter. Fill (DS );

Xmldatadoc= NewXmldatadocument (DS );
}
Catch
{
Xmldatadoc= Null;
}
Finally
{
Strcon= Null;
DS. Dispose ();
}
Return Xmldatadoc;

}

We can note that. Xmldatadocument is used here. Remember Lu FeiArticleMentioned in XML document, do we need to manually modify it? In fact, this is not necessary. We can associate the xmldatadocument with dataset to generate the corresponding XML

2. Create a New Reporting Services Project. Note that the reporting serverices project is not a report viewer control. For their differences, see:
Http://msdn2.microsoft.com/zh-cn/library/ms345248.aspx

Create a datasource in shared data source and specify the type as XML. The connection string is your webserivce, for example, http: // localhost/WebService/service. asmx (you may need to deploy WebService in IIS)

Create a report and specify the query string as follows:
<Query xmlns = "http://Eric.org/">
<Soapaction> http://Eric.org/GetDataSource </soapaction>
</Query>

For the query string Syntax of WebService, see:
Http://msdn2.microsoft.com/en-us/library/ms345251.aspx

Then you can obtain the data.

One problem I encountered during the process is that if the default WebService namespace created in vs is a http://tempuri.org/,Query string check, an error is reported, you only need to change a namespace (if I change to a http://Eric.org)

The advantage of this is that you can use the visual report design system of reporting services.

I haven't written any articles for a long time. Please kindly ask :)

References:
Http://www.codeproject.com/aspnet/WebAndReportingServices.asp

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.