转:使用WebService动态生成DataSet绑定到Reporting Services
发布时间:2020-12-17 02:37:28 所属栏目:安全 来源:网络整理
导读:使用WebService动态生成DataSet绑定到Reporting Services 转自:http://tech.sina.com.cn/s/2008-07-01/0833714471.shtml ? 【IT168技术文档】 ? 我的步骤是这样的: ? 1.首先创建一个WebSerivce,然后写了一个Web Method: [WebMethod] public XmlDataDocumen
使用WebService动态生成DataSet绑定到Reporting Services转自:http://tech.sina.com.cn/s/2008-07-01/0833714471.shtml ? 【IT168技术文档】 ? 我的步骤是这样的: ? 1.首先创建一个WebSerivce,然后写了一个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 = new XmlDataDocument(ds); } catch { xmlDataDoc = null; } finally { strCon = null; ds.Dispose(); } return xmlDataDoc; }
? 我们可以注意到。这里使用了XmlDataDocument,还记得陆飞文章中提到了XML文档,我们需要受到手动修改它吗?其实是不需要的,我们可以通过XmlDataDocument关联到DataSet生成相应的XML
? 2.新建一个Reporting Services项目,注意时Reporting Serverices项目,不是Report Viewer控件 ? 然后在Shared Data Source里新建一个DataSource,指定Type为XML,Connection String 为你的WebSerivce,比如说 http://localhost/WebService/Service.asmx(你可能需要在IIS中部署WebService) ? 然后新建一个Report,指定Query String 为:? <Query xmlns="http://Eric.org/"> <SoapAction>http://Eric.org/GetDataSource</SoapAction> </Query> ?? 然后就可以取得数据了。 ? 过程中,我遇到的一个问题是,如果在VS中创建的默认的WebService Namespace为http://tempuri.org/,Query String检查就会报错,你只要更改一个Namespace就可以了(如果说我改成了http://Eric.org) ? 这样做的好处显而易见,就是可以使用Reporting Services的可视化报表设计系统了。
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |