开发者

Programmatically upload XML file to SSRS server

开发者 https://www.devze.com 2022-12-29 18:45 出处:网络
How do I programmatically upload an XSLT file to an SSRS se开发者_运维知识库rver database? I would like exactly the same functionality as the \'Upload File\', preferably using the \'rs\' command.

How do I programmatically upload an XSLT file to an SSRS se开发者_运维知识库rver database? I would like exactly the same functionality as the 'Upload File', preferably using the 'rs' command.

I have tried rs.CreateResource, but it doesn't seem to work for XML/XSLT files (though it works for Excel and image files)

I understand that manipulating the SSRS db is not supported.


This is the code SSMS generated when I tried to upload an xml file:- Dim Resource As String = "home" Dim Parent As String = "/" Dim Overwrite As Boolean = false Dim Contents() As Byte = New Byte() {} Dim MimeType As String = "text/xml" Dim Properties(-1) As Microsoft.SqlServer.ReportingServices2005.[Property]

RS.CreateResource(Resource, Parent, Overwrite, Contents, MimeType, Properties)

Are you specifying the correct MimeType?


Finally found the problem. The XSLT file was getting uploaded with a trailing null byte at the end of file. Had to use a Hex viewer to see this.

To fix it I copied the array into another array, minus the last character and it's all good now.

Dim Temp() As Byte = New Byte(ArrayLength-1) {}
For i As Integer = 0 To ArrayLength-1
  Temp(i)=Contents(i)
Next
rs.CreateResource(XSLTFileName, ReportFolder, True, Temp, "application/xml", Nothing)
0

精彩评论

暂无评论...
验证码 换一张
取 消