
{"id":1248,"date":"2013-05-03T12:02:12","date_gmt":"2013-05-03T16:02:12","guid":{"rendered":"http:\/\/www.ikriv.com\/blog\/?p=1248"},"modified":"2013-05-03T12:02:12","modified_gmt":"2013-05-03T16:02:12","slug":"ssrs-production-deployment-part-2","status":"publish","type":"post","link":"https:\/\/ikriv.com\/blog\/?p=1248","title":{"rendered":"SSRS Production Deployment, Part 2"},"content":{"rendered":"<p>In <a href=\"http:\/\/www.ikriv.com\/blog\/?p=1237\">Part 1<\/a> we discussed that in development environemnt we deploy reports by simply clicking &#8220;Deploy&#8221; in BIDS, but this won&#8217;t work in production. To deploy reports in production we need to write an SSRS script, which is actually a piece of VB.NET code executing against <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms155071.aspx\">SSRS web service<\/a>.<\/p>\n<p>A typical report consists of the report definition (the <code>.rdl<\/code> file) that references one or more <i>data sources<\/i>. And this is where things get tricky.<\/p>\n<p><b>Deploying Data Sources<\/b><\/p>\n<p><a href=\"http:\/\/www.ikriv.com\/dev\/misc\/ssrs\/DeployRds.vb\">Code to deploy a data source<\/a>.<br \/>\n<a href=\"http:\/\/www.ikriv.com\/dev\/misc\/ssrs\/Deploy.vb\">Code to deploy data source and report<\/a>.<\/p>\n<p>You create a data source using a call to <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/reportservice2010.reportingservice2010.createdatasource.aspx\">rs.CreateDataSource()<\/a> method. Unfortunately, this method does not accept <code>.rds<\/code> files that BIDS uses to store data source information. Instead it wants a <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/reportservice2010.datasourcedefinition.aspx\">DataSourceDefinition<\/a> object. This means that one must parse the <code>.rds<\/code> file and convert it to a <code>DataSourceDefinition<\/code> instance. Here&#8217;s a piece of code that does that. It is geared for datasources with integrated credentials, if you use other kind of credentials, you&#8217;ll need to make relevant modifications.<\/p>\n<p><code><\/p>\n<pre>Dim doc As System.Xml.XmlDocument = New System.Xml.XmlDocument\ndoc.Load(rdsPath)\n\nDim dataSource As DataSourceDefinition = New DataSourceDefinition\ndataSource.ConnectString = doc.SelectSingleNode(\"\/RptDataSource\/ConnectionProperties\/ConnectString\/text()\").Value\ndataSource.Extension = doc.SelectSingleNode(\"\/RptDataSource\/ConnectionProperties\/Extension\/text()\").Value\ndataSource.CredentialRetrieval = CredentialRetrievalEnum.Integrated\ndataSource.Enabled = True\ndataSource.EnabledSpecified = True\n\nDim name As String\nname = doc.SelectSingleNode(\"\/RptDataSource\/Name\/text()\").Value\n\nDim overwrite As Boolean = false\n\nrs.CreateDataSource(name, \"\/Data Sources\", overwrite, dataSource, Nothing)<\/pre>\n<p><\/code><\/p>\n<p>This was easy, wasn&#8217;t it? Full version of the code with logging and error handling can be found <a href=\"http:\/\/www.ikriv.com\/dev\/misc\/ssrs\/DeployRds.vb\">here<\/a>.<\/p>\n<p>But data sources are only one half of the story. In <a href=\"http:\/\/www.ikriv.com\/blog\/?p=1261\">Part 3<\/a> we will discuss how to deploy reports.<\/p>\n<p><a style=\"display:none\" href=\"http:\/\/www.codeproject.com\/script\/Articles\/BlogFeedList.aspx?amid=1181663\" rel=\"tag\">CodeProject<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Part 1 we discussed that in development environemnt we deploy reports by simply clicking &#8220;Deploy&#8221; in BIDS, but this won&#8217;t work in production. To deploy reports in production we <a href=\"https:\/\/ikriv.com\/blog\/?p=1248\" class=\"more-link\">[&hellip;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":"","footnotes":""},"categories":[14],"tags":[],"class_list":["entry","author-ikriv","post-1248","post","type-post","status-publish","format-standard","category-db"],"_links":{"self":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1248","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1248"}],"version-history":[{"count":0,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1248\/revisions"}],"wp:attachment":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1248"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1248"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1248"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}