1

問題: SQL Server 2005 BIDS を使用して SSIS ジョブを作成しようとしています。ジョブには、スクリプト タスクと電子メール タスクが含まれます。最後のステップでスクリプト タスクが失敗し、次のエラーが発生します。

行セットを開けませんでした。詳細: ADO エラー コード: 0x ソース: Microsoft OLE DB Provider for SQL Server 説明: プロシージャまたは関数 'usp_xtal_InHouse_Penetration_Summary' には、指定されていないパラメーター '@DateStart' が必要です。

SQL 状態: 42000 ネイティブ エラー: 行セットを開くことができませんでした。ファイル C:\DOCUME~1\TEMP~1.SUM\LOCALS~1\Temp\1\auto_Inhouse_Leads_Penetration {5DA4C113-6AFC-4EB2-94E8-7D0F12E03C52}.rpt のエラー: 行セットを開くことができませんでした。

この問題は、呼び出されたレポートがストアド プロシージャから実行されていることが原因であると考えられます。レポートが実際にパラメータを SP に渡すかどうかはわかりません。これは、探している最初のパラメーターが指定されていないことを示す SQL エラーであるためだと思います。SP は、このスクリプトで宣言されているパラメーターのみを探しており、スクリプトは SP とまったく同じ順序でパラメーターを宣言、設定、およびロードしています。

同様の SSIS ジョブを実行している他のレポートがありますが、SP を使用しているものはありません。

任意の考えをいただければ幸いです。

私が提供している次のスクリプトには、さまざまな場所にいくつかの msgbox() があり、変数が正しくロードされているかどうか、およびスクリプトがその時点まで実行されているかどうかを確認しています。最後のエラーで上記のエラーで失敗します。

Public Class ScriptMain
    Public Sub Main()
        '
        Dim CrystalReportViewer1 As New CrystalDecisions.Windows.Forms.CrystalReportViewer
        Dim DiskOpts1 As New CrystalDecisions.Shared.DiskFileDestinationOptions
        Dim myExportOptions1 As New CrystalDecisions.Shared.ExportOptions

        DiskOpts1.DiskFileName = "\\10.200.0.7\c$\Jobs\Arrivals\WeeklyInhousePenetrationReport.pdf"
        myExportOptions1.ExportFormatType = myExportOptions1.ExportFormatType.PortableDocFormat
        myExportOptions1.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile
        myExportOptions1.ExportDestinationOptions = DiskOpts1

        ' Verify the path to the Crystal Report's .RPT file:
        Dim strReportPath1 As String = "\\10.200.0.7\c$\Jobs\Arrivals\auto_Inhouse_Leads_Penetration.rpt"

        If Not System.IO.File.Exists(strReportPath1) Then
            Throw (New Exception("Unable to locate report file:" & _
            vbCrLf & strReportPath1))
        End If

        ' Load the Crystal report's .RPT file:
        Dim cr1 As New CrystalDecisions.CrystalReports.Engine.ReportDocument

        'Dim ParamVal1 As New ParameterDiscreteValue
        'Dim ParamVal2 As New ParameterDiscreteValue
        Dim ParamVal3 As New ParameterDiscreteValue
        Dim ParamVal4 As New ParameterDiscreteValue
        Dim ParamVal5 As New ParameterDiscreteValue



        cr1.Load(strReportPath1)

        'Set the logon credentials of the main report---change these values
        LogonToDatabase(cr1.Database.Tables, "SomeInstance", "SomeUserName", "SomePassword")

        'ParamVal1.Value = 2
        'ParamVal2.Value = False
        ParamVal3.Value = DateAdd(DateInterval.Day, -15, Date.Today)
        ParamVal4.Value = DateAdd(DateInterval.Day, -8, Date.Today)
        ParamVal5.Value = "All"

        MsgBox(ParamVal3.Value, , "Param 3")  'Good to here

        'cr1.SetParameterValue("param_SiteID", ParamVal1)
        'cr1.SetParameterValue("param_Detail", ParamVal2)
        cr1.SetParameterValue("DateStart", ParamVal3)
        cr1.SetParameterValue("DateEnd", ParamVal3)
        cr1.SetParameterValue("Agent", ParamVal3)

        MsgBox(ParamVal4.Value, , "ParamVal4")  'Good to here

        ' Set the CrystalReportViewer's appearance and set the ReportSource:
        ' This may not be needed but I kept them anyhow
        CrystalReportViewer1.ShowRefreshButton = False
        CrystalReportViewer1.ShowCloseButton = False
        CrystalReportViewer1.ShowGroupTreeButton = False

        CrystalReportViewer1.ReportSource = cr1

        MsgBox(ParamVal5.Value, , "ParamVal5")  'Good to here


        cr1.Export(myExportOptions1)            '  Failing at this step

        MsgBox(ParamVal3.Value, , "ParamVal3")  'Never gets here
        '
        Dts.TaskResult = Dts.Results.Success
    End Sub

    Private Sub LogonToDatabase(ByVal ReportTables As CrystalDecisions.CrystalReports.Engine.Tables, ByVal ServerName As String, ByVal UserId As String, ByVal Password As String)
        ' To Supply Logon Information to each and every Tables used in the Report
        Dim myTable As CrystalDecisions.CrystalReports.Engine.Table
        Dim myConnectionInfo As New CrystalDecisions.Shared.ConnectionInfo()
        Dim myLogonInfo As New CrystalDecisions.Shared.TableLogOnInfo()
        myConnectionInfo.UserID = UserId
        myConnectionInfo.Password = Password
        myConnectionInfo.ServerName = ServerName
        myLogonInfo.ConnectionInfo = myConnectionInfo
        For Each myTable In ReportTables
            myTable.ApplyLogOnInfo(myLogonInfo)
        Next    

    End Sub
End Class
4

0 に答える 0