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