Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
876 views
in Technique[技术] by (71.8m points)

reporting services - SSRS -parameters sent from VB.NET Code to SSRS reports are not being recognized ,VB.NET and SSRS have different providers in connection string

We have a VB.NET application from which parameter are passed to SSRS reports with arabic content ,our database is IBM DB2.There are two different connection strings with different providers ,in SSRS we use the below connection string as this is printing arabic text in correct order,if i use IBMDASQL.DataSource.1 provider arabic text is rendered in reverse

  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

In VB.NET code we use this connection string ,this is a legacy application and i cannot change the provider for this as in 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>" />

When I try to pass parameters from VB.NET code to SSRS I get the below error

“This report requires a default or user-defined value for the report parameter 'prsFRANCHISE'. To run or subscribe to this report, you must provide a parameter value.” If both connection strings have same provider IBMDASQL.DataSource.1 i am able to render the report succesfully ,only thing is arabic words are in reverse .

I tried to look for setting connection string in vb.net code behind just before i call render report, but there are no methods provided for ServerReport to set connection string

I set parameters using this code

**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)**

This is my ServerExport method

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

I get error in pageStream = report.Render("IMAGE", deviceInfo, firstPageParameters, "image/jpeg", ".jpeg")

where it is unable to recognize paraemeter passed

question from:https://stackoverflow.com/questions/65884234/ssrs-parameters-sent-from-vb-net-code-to-ssrs-reports-are-not-being-recognized

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The last two parameters in the .Render method are out parameters. Meaning you'd have to supply a local variable for the method to assign data to.

So change:

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

To:

Private mime As String
Private extension As String

pageStream = report.Render("IMAGE", deviceInfo, firstPageParameters, mime, extenstion)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...