http://www.csdn.net/expert/topic/655/655298.xml?temp=.8215296

解决方案 »

  1.   

    to fuxc(Michael)我去过那了,我只是想要哪位兄弟给我发一份做报表的原码,谢谢
      

  2.   

    我的办法是
    建一个表,跟存储过程的字段一样,然后用根据这个表作DATAREPORT
    在程序中用Rs返回存储过程的记录集,赋给报表的字段其实建表是为了作报表用
      

  3.   

    to lihonggen0(李洪根,用VB,标准答案来了) :能说的清楚一点吗?这个表是临时表还是永久表啊?谢谢
    to songyangk(小草) :怎么把结果集赋值给报表?我不懂啊,能说的清楚一点吗?谢谢
      

  4.   

    不用建表,在存储过程中把结果集查出来就行了。
    Select xxxx From xxxx......
    对于ADO,表、视图和存储过程的结果集返回的方法都是一样的
      

  5.   

    但是对DATAREPORT不一样啊,怎么联系呢?
      

  6.   

    我的办法是建立临时表,做完报表后将表删除
    调用存储过程的时候,将结果(即记录集)返回给DataReport的字段
    我是这样用的,不如有没有更好的办法
    在数据环境中可以选择表,视图,存储过程,即可将字段拖入DataReport
      

  7.   

    做完报表后将表删除?是在哪里写这段呢?能不能给我一段源程序?
    我的 [email protected]
    我一定会结贴的,谢谢
      

  8.   

    '这段代码你可能不能运行,但你可以参考一下
    打印过程设数据源用语句写就行,得到 存储过程的Rs 
    即写报表的datasource
    datamemberPrivate Sub sscmdOK_Click(Index As Integer)
        Dim SQLPrint As String
        Dim J As Integer
        Dim XX As String
        Dim Bb As Integer
        SQLPrint = "Exec shhy"      '执行存储过程
        ReportPrint "com_jc_shhy", SQLPrint, Dr_Jc_Shhy1
        
        DE_Report.Con_report.Close
        OpenDEConnection
        '打印选择
        If SSOption1(0).Value = True Then             '正文
            ReportPrint "com_jc_shhy", SQLPrint, Dr_Jc_Shhy1
            Call TaoPrint(Dr_Jc_Shhy1, nPrintMode)
            If W_Jc_Shhy.Text1(9).Text = "TO BE COVERED BY THE BUYERS." Then
               Dr_Jc_Shhy1.Sections(3).Controls("label46").Visible = True
               Dr_Jc_Shhy1.Sections(3).Controls("Label47").Visible = True
               Dr_Jc_Shhy1.Sections(3).Controls("Label48").Visible = True
               Dr_Jc_Shhy1.Sections(3).Controls("Label49").Visible = True
            Else
               Dr_Jc_Shhy1.Sections(3).Controls("Label46").Visible = False
               Dr_Jc_Shhy1.Sections(3).Controls("Label47").Visible = False
               Dr_Jc_Shhy1.Sections(3).Controls("Label48").Visible = False
               Dr_Jc_Shhy1.Sections(3).Controls("Label49").Visible = False
            End If
            Dr_Jc_Shhy1.Show 1
        Else
            If SSOption1(1).Value = True Then         '附页
                XX = mmLine(Rs_Jc_Shhy.Fields("addpage"))
                
                ReportPrint "com_jc_shhy", SQLPrint, Dr_Jc_Shhy2
                Call TaoPrint(Dr_Jc_Shhy2, nPrintMode)
                Bb = 1
                Dr_Jc_Shhy2.Sections(3).Controls("LABEL2").Caption = Bb
                Dr_Jc_Shhy2.Show 1
                If XX > 53 Then
                    Bb = 2
                    For i = 1 To Int(XX / 53)
                        ReportPrint "com_jc_shhy", SQLPrint, Dr_Jc_Shhy2
                        Dr_Jc_Shhy2.Sections(3).Controls("TXTaddpage").Visible = False
                        Dr_Jc_Shhy2.Sections(3).Controls("LABEL23").Caption = ""
                        For J = i * 53 + 1 To (i + 1) * 53
                            Dr_Jc_Shhy2.Sections(3).Controls("LABEL23").Caption = Dr_Jc_Shhy2.Sections(3).Controls("LABEL23").Caption & Mline(Rs_Jc_Shhy.Fields("addpage"), J) & Chr(10) & Chr(13)
                        Next J
                        Dr_Jc_Shhy2.Sections(3).Controls("LABEL23").Visible = True
                        Dr_Jc_Shhy2.Sections(3).Controls("LABEL2").Caption = Bb
                        Dr_Jc_Shhy2.Show 1
                        Bb = Bb + 1
                    Next i
                End If
            Else
                If SSOption1(2).Value = True Then     '背面
                    ReportPrint "com_jc_shhy", SQLPrint, Dr_Jc_Shhy3
                    Call TaoPrint(Dr_Jc_Shhy3, nPrintMode)
                    Dr_Jc_Shhy3.Show 1
                End If
            End If
        End If
        Unload Me
    End Sub
      

  9.   

    你可以去
    www.21code.com
    www.vbeden.com
    www.vbgood.com
    www.helpwork.net
    看一下