我新建一个报表实例m_Report,报表里有几个未绑定字段,我想要用数据库中的内容绑定这此未绑定字段,
以下是水晶报表9.2 示例中的代码,代码不会有问题.但是执行到第一句时报错:

实时错误 '-2147189571 (80047cbd)':
未启用创建功能这是什么意思?我用的是水晶报表9专业版,并已经注册了的.
m_Report.Database.AddOLEDBSource DataEnvironment1.Connection1, "Orders"
'上面这句不能执行,报错.
    
' Bind the five unbound fields to the newly added data source
    With m_Report
        .UnboundString1.SetUnboundFieldSource "{Orders.Ship Via}"
        .UnboundCurrency1.SetUnboundFieldSource "{Orders.Order Amount}"
        .UnboundBoolean1.SetUnboundFieldSource "{Orders.Shipped}"
        .UnboundNumber1.SetUnboundFieldSource "{Orders.Customer ID}"
        .UnboundDate1.SetUnboundFieldSource "{Orders.Order Date}"
    End With
并且我发现 Database.AddADOCommand 这个命令也报一样的错误.难道专业版不提供此功能?(水晶报表8。0不会出错!) 我只好以Rs集来绑定报表中的未绑定字段
m_Report.Database.SetDataSource Rs但是后面的代码怎么写? 怎样用 RecordSet 集绑定水晶报表中未绑定字段?
谢谢各位!

解决方案 »

  1.   

    Declare Function SetActiveDataSource Lib "p2smon.dll" (ByVal printJob As Integer, ByVal tableNum As Integer, x As Object) As Long
    先加上引用
    Declare Function vbEncodelPtr Lib "p2smon.dll" (x As Object) As String
    Declare Function CreateFieldDefFile Lib "p2smon.dll" (lpUnk As Object, ByVal fileName As String, ByVal bOverWriteExistingFile As Long) As Long
    Global job As Integer
    Global Handle As Integer
    代码:
            Handle = PEOpenEngine
            If Handle = 0 Then
                Me.MousePointer = 0
                MsgBox "A failure occurred when opening the Print Engine."
                MsgBox "The error code is: " & PEGetErrorCode(Handle) 'ErrorNum
                PEClosePrintJob job
                PEClosePrintJob subReportjob
                PECloseEngine
            End If
            job = PEOpenPrintJob(strPath)
            Handle = SetActiveDataSource(job, 0, adoRs)
            Handle = PEOutputToWindow(job, GetRptName(strPath), 0, 0, 520, 520, 0, 0) 'WS_MAXIMIZE, 0)
            iResult = PESetWindowOptions(job, Windowoptions)
            If iResult = 0 Then ' PESetWindowOptions failed
                Screen.MousePointer = vbDefault
                PEClosePrintJob job
                PEClosePrintJob subReportjob
                PECloseEngine
                Exit Sub
            End If
            If Handle <> 0 Then
                Handle = PEStartPrintJob(job, True)
                If Handle <> 0 Then
                    'MsgBox "The report is printing."
                Else
                    Me.MousePointer = 0
                    PEClosePrintJob job
                    PEClosePrintJob subReportjob
                    PECloseEngine
                    MsgBox "An error occurred while trying to Start the Print Job."
                    MsgBox "The error code is:" & PEGetErrorCode(job) 'ErrorNum
                End If
            Else
                Me.MousePointer = 0
                PEClosePrintJob job
                PEClosePrintJob subReportjob
                PECloseEngine
                MsgBox "The output cannot be sent to the window."
                MsgBox "The error code is: " & PEGetErrorCode(job) 'ErrorNum
            End If
        End If
        PEClosePrintJob job
        PEClosePrintJob subReportjob
        PECloseEngine
    这是在8.5下的ttx类型的报表,不知是否适合你的要求
      

  2.   

    http://support.crystaldecisions.com/library/kbase/articles/c2012093.asp
      

  3.   

    English?!!!对不起,只看得懂一点,但不知道怎么做。请问,具体应该怎么做才能使用
    Database.AddADOCommand  和  m_Report.Database.AddOLEDBSource 功能,
    我想 desrie(leir)应该解决了吧!
      

  4.   

    Sorry ,nobody can help you until you purchase a RCAPI license .