Programatically upload XML file to SSRS server

一笑奈何 提交于 2019-12-24 20:19:34

问题


How do I programatically upload an XSLT file to an SSRS server 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. Thanks


回答1:


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?




回答2:


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)


来源:https://stackoverflow.com/questions/2770210/programatically-upload-xml-file-to-ssrs-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!