首先,我创建了一个父报表,父报表中没有具体的记录,接着在该报表中插入一个子报表,检索的相关记录在字报表中设计。程序打印的时候,总是提示20599错误,应该是SQL Server连接问题,请问怎样能够让代码中传递给父报表的DB连接和子报表连接上?
    我在设计的报表中预览时候没有问题,显示的结果就是从DB中取得的记录,请问是什么原因

解决方案 »

  1.   

    Private Sub cmdPrint_Click()
        
        If m_enmOutputMethod = omTekiyouYMD And (Trim(txtYear.Text) = "" Or Trim(txtMonth.Text) = "") Then
            Call ShowMessage("300008")
            Exit Sub
        End If
        
        If m_iNumOfOutItems <= 0 Then
            Call ShowMessage("300009")
            Exit Sub
        End If
        
        
        crPrint.Connect = "DSN = " & g_tJeassIniInfo.strDSN & ";" & _
                          "UID = " & g_tJeassIniInfo.strUserID & ";" & _
                          "PWD = " & g_tJeassIniInfo.strPassword & ";DSQ= "
        
        '' 印刷
        frmOutProcessing.m_iOutType = 1
        frmOutProcessing.Show vbModal
        
    End Sub;crPrint是水晶报表控件
      

  2.   

    strSQL = GetSQL(m_enmOutputMethod, ip_iIndex)
            strRptFile = GetOutputItemInfo(ikRptFileName, ip_iIndex)
            strItemName = GetOutputItemInfo(ikItemName, ip_iIndex)
            
            crPrint.ReportFileName = g_tJeassIniInfo.strSystemDir & "\CrystalReport\" & strRptFile
            crPrint.Formulas(0) = "fSiteiYMD = """ & strSiteiYMD & """"
            crPrint.Formulas(1) = ""
            crPrint.Formulas(2) = ""
            crPrint.Formulas(3) = ""
            crPrint.Formulas(4) = ""
            crPrint.Formulas(5) = ""
            crPrint.Formulas(6) = ""
            
            crPrint.SQLQuery = strSQL
            iRtv = crPrint.PrintReport
            If iRtv <> RET_OK Then
                Call ShowMsgWithParams("410038", , strItemName)
            End If
    ;在程序里面设置要打印的报表的sql语句,但是不知道怎么设置子报表的sql文