SSRS -从VB发送的参数.. NET代码到SSRS报告不被识别,VB.. NET和SSRS在连接字符串中有不同的提供



我们有一个VB。NET应用程序,其中参数传递给带有阿拉伯语内容的SSRS报告,我们的数据库是IBM DB2。有两个不同提供程序的不同连接字符串,在SSRS中我们使用下面的连接字符串,因为如果我使用IBMDASQL.DataSource,这将以正确的顺序打印阿拉伯文本。提供者阿拉伯语文本以反向方式呈现

Provider=Microsoft OLE DB Provider for DB2;User ID=<your used id>;Initial Catalog=dbsys2;Network Transport Library=TCP;Host CCSID=20420;PC Code Page=1256;Network Address=S44CB295;Network Port=446;Package Collection=VEHICLE;Default Schema=VEHICLE;Process Binary as Character=False;Units of Work=RUW;Default Qualifier=VEHICLE;DBMS Platform=DB2/AS400;Persist Security Info=False;Connection Pooling=True

VB。. NET代码中,我们使用这个连接字符串,这是一个遗留应用程序,我不能像在SSRS

中那样更改它的提供者。
<add name="ConnStr" connectionString="Provider = IBMDASQL.DataSource.1;Persist Security Info = True;Data Source = SYSPRD01;Default Collection = VEHICLE;Convert Date Time To Char = FALSE;Use SQL Packages = False;Add Statements To SQL Package = False;User ID = <your user id>; Password =<your password>" />

当我试图从VB传递参数。. NET代码到SSRS,我得到以下错误

"此报告需要报告参数'prsFRANCHISE'的默认值或用户定义的值。要运行或订阅此报表,必须提供参数值。如果两个连接字符串具有相同的提供程序IBMDASQL.DataSource。1 .我能成功地完成报告,只是阿拉伯语单词反了。

我试图在vb.net代码中寻找设置连接字符串,就在我调用渲染报告之前,但是没有为ServerReport提供方法来设置连接字符串

我使用以下代码设置参数

**report.ReportServerUrl = New System.Uri(ldtReportParameter.Rows(0).Item("RMREPTSERV").ToString.Trim)
report.ReportPath = ldtReportParameter.Rows(0).Item("RMREPTPATH").ToString.Trim
laIndividualParameters(0) = New ReportParameter("prsFRANCHISE", row.Cells(4).Text.ToString().Trim(), False)
laIndividualParameters(1) = New ReportParameter("prsBRAN", row.Cells(5).Text.ToString().Trim(), False)
laIndividualParameters(2) = New ReportParameter("prsDEPT", row.Cells(6).Text.ToString().Trim(), False)
laIndividualParameters(3) = New ReportParameter("prsPRNO", row.Cells(3).Text.ToString().Trim(), False)
laIndividualParameters(4) = New ReportParameter("prsCopy", row.Cells(2).Text.ToString().Trim(), False)
report.SetParameters(laIndividualParameters)
ServerExport(report)
lsPrintStatus = Print(row.Cells(9).Text.ToString().Trim(), liNumberofCopies)**

是我的ServerExport方法

Private Sub ServerExport(ByVal report As ServerReport)
Try
Dim deviceInfo As String = "<DeviceInfo> <OutputFormat>EMF</OutputFormat> <PageWidth>8.5in</PageWidth> <PageHeight>11in</PageHeight> <MarginTop>0.25in</MarginTop> <MarginLeft>0.25in</MarginLeft><MarginRight>0.25in</MarginRight><MarginBottom>0.25in</MarginBottom></DeviceInfo>"
Dim warnings As Warning()
m_streams = New List(Of Stream)()
Dim pageStream As Stream
Dim firstPageParameters As NameValueCollection = New NameValueCollection()
firstPageParameters.Add("rs:PersistStreams", "True")
firstPageParameters.Add("rs:Command", "ClearSession")
Dim nonFirstPageParameters As NameValueCollection = New NameValueCollection()
nonFirstPageParameters.Add("rs:GetNextStream", "True")

pageStream = report.Render("IMAGE", deviceInfo, firstPageParameters, "image/jpeg", ".jpeg")
While pageStream.Length > 0
m_streams.Add(pageStream)
pageStream = report.Render("IMAGE", deviceInfo, nonFirstPageParameters, "image/jpeg", ".jpeg")
End While

Catch ex As Exception
Master.AlertMessageBox(ex.Message)
End Try
End Sub

我在pageStream = report.Render("IMAGE", deviceInfo, firstPageParameters, "image/jpeg", ".jpeg")

中得到错误无法识别传递的参数

.Render方法中的最后两个参数为out参数。这意味着您必须为方法提供一个局部变量来分配数据。

所以改变:

pageStream = report.Render("IMAGE", deviceInfo, firstPageParameters, "image/jpeg", ".jpeg")

:

Private mime As String
Private extension As String
pageStream = report.Render("IMAGE", deviceInfo, firstPageParameters, mime, extenstion)

相关内容

  • 没有找到相关文章

最新更新