0

场景:使用 rs.exe 使用 srrs 上传图像(使用代码而不是 GUI)

环境:Sql server 2012, rs.exe , vb.script

'Utility to Publish the Png file ( snippet)
'Sample inputs PublishImageFile("myimagefilename.png", "image/png")
Public Sub PublishImageFile(ByVal imageName As String,ByVal resourceMIME As String)

Try
    Dim stream As FileStream = File.OpenRead(filePath + "\" + imageName)
    definition = New [Byte](stream.Length - 1) {}
    stream.Read(definition, 0, CInt(stream.Length))
    stream.Close()
Catch e As IOException
    Console.WriteLine(e.Message)
End Try

imageName = imageName.tostring.replace(".png", "")
Console.WriteLine("Attempting to Deploy Resource Name {0}", imageName.tostring)
Dim item As CatalogItem
Dim mimeProperty As New  Microsoft.SqlServer.ReportingServices2010.Property
mimeProperty.Name = "MimeType"
mimeProperty.Value = resourceMIME
Dim properties(1) As Microsoft.SqlServer.ReportingServices2010.Property
properties(0) = mimeProperty 

Try
    item = rs.CreateCatalogItem("Resource", imageName, ReportFolder, True, 
                            definition, properties, warnings) 'Error line
    'More code below removed for brevity 

我在上面最后一行收到的错误是

输入结构中缺少必填字段属性。---> Microsoft.ReportingServices.Diagnostics.Utilities.MissingElementException:输入结构中缺少必填字段属性。

属性对象中解决问题所需的参数是什么。

我在 MSDN https://msdn.microsoft.com/en-us/library/reportservice2010.reportingservice2010.createcatalogitem(v=sql.120).aspx的 CreateCatalogitem 方法中没有找到相同的

也不在 MSDN 的目录项描述中

https://msdn.microsoft.com/en-us/library/reportservice2010.catalogitem.aspx

从错误消息和调查来看(我的假设),属性数组中可能缺少名为“Property”的必填字段。但它的价值是什么?

请分享您的建议和解决方案,或者甚至可能是 rs.exe 的代码替代品,以使用脚本自动将图像部署到 ssrs。

4

1 回答 1

0

我找到了答案。我刚刚在 CreateCatalogItem 方法之前添加了一个名为 property 和 name 作为文件名的附加属性,它起作用了!

Dim propertyItem As New  Microsoft.SqlServer.ReportingServices2010.Property
propertyItem.Name = "Property"
propertyItem.Value =  imageName
properties(1) = propertyItem 
于 2016-10-13T00:58:33.447 回答