回复: ferrytang
 说的好,我猜也是这个原因,但该怎样释放呢?

解决方案 »

  1.   

    不知道直接设置"报表对象=Nothing"是否可行
      

  2.   

    回复:Fanks(凡可) 
         我把报表对象动态的卸掉了都不行,一定要把应用程序停下来才可以     您能给出具体的代码吗?
      

  3.   

    我所说的只是猜测,比如Connection对象即使使用了Close方法,但还没有释放内存,还要Set Connection=Nothing才行,所以我想,你卸掉报表对象后,再加一句"Set 报表对象=Nothing",但我没有crystal report,无法测试,只能你试了。
      

  4.   

    回复Fanks(凡可) :
    我尝试过,但内存没释放
      

  5.   

    我写的原码如下:Frmmain.CrystalReport1(1).Destination = crptToFile
    Frmmain.CrystalReport1(1).PrintFileType = crptCrystal
    Frmmain.CrystalReport1(1).PrintFileName = App.Path & "\" & "rpt\" & outfilename & ".rpt"
    Frmmain.CrystalReport1(1).ReportFileName = App.Path & "\" & programname
    Frmmain.CrystalReport1(1).connect = connect
    Frmmain.CrystalReport1(1).SelectionFormula = SelectionFormula
    Frmmain.CrystalReport1(1).ProgressDialog = False
    Frmmain.CrystalReport1(1).Action = 1
      

  6.   

    Determines whether or not the Crystal Report Engine can be closed. Use this function before calling PECloseEngine to verify that the engine is no longer processing print jobs. If the Crystal Report Engine closes while a print job is still running, an error can occur in your application or on the user's system.BOOL CRPE_API PECanCloseEngine (void); Return Value TRUE (1) if the Engine can be closed; FALSE (0) if the Engine is busy.
      

  7.   

    yell(飞空草) :
    我不太明白你说的
      

  8.   

    就是说在调用PECloseEngine函数关闭报表引擎前先调用PECanCloseEngine函数看看返回值.返回1,允许关闭;返回2,说明引擎正忙,此时关闭会引发错误
      

  9.   

    回复yell(飞空草) :
         那怎样关闭报表引擎呢?
         能给出关闭引擎的原码?
      

  10.   

    我也被这个问题困扰,就是在设计期间如果多run几次也会遇到这样的问题。
    好像是crystal report本身的问题,升级到8.0会不会好一点呢?
    关于报表对象释放问题,连crystal report教称本身也没有提到这样释放是不是有效。
    :(
      

  11.   

    yell(飞空草) 说的也许有效
    但可能用不行CrystalReport1控件
    我也用过CrystalReport1控件,控件过多连VB都打不开,一直报内存不足
    后来我改用了CrystalReport的API函数来编程就没问提了
    CrystalReport的API函数的帮助在CrystalReport的安装目录下有
    好像是DEVELOP目录
    还有两个模块文件
    用CrystalReport的API函数时要添加到工程中
    试试吧.祝好运
      

  12.   

    参考:wangsitao(飞猪) 
    关于我提出的几个函数,crystal report 6.0 的帮助中有详细说明
      

  13.   

    您好,谢谢您的回答,我还没有解决这个问题,
    yell(飞空草)说的方法没有效果, 
    关于您用的方法,能否再说清楚点,
    您用了哪几个CrystalReport的API函数,
    能否发一份详细说明到                            谢谢
    (如果您能帮我度过难关,150分一定如数奉上)
    -------------------------------------------------------------------------
    调用crystal report控件打印两百来张报表后,系统内存会被耗尽,将应用程序重启后,
    内存才能被释放。
      

  14.   

    一点建议:
    打开windows的资源监视器,添加监视物理内存占用的项目,然后单步执行你的程序,观察到底那些语句占用内存不释放,然后再考虑解决方法~
      

  15.   

    这句
    Frmmain.CrystalReport1(1).Action = 1
      

  16.   

    大家请看源程序:Frmmain.CrystalReport1.Destination = crptToFile
    Frmmain.CrystalReport1.PrintFileType = crptPagedText
     
    Frmmain.CrystalReport1.PrintFileName = App.Path & "\" & "temp\" & outfilename & ".txt"
    Frmmain.CrystalReport1.ReportFileName = App.Path & "\" & programname
    Frmmain.CrystalReport1.connect = connect
    Frmmain.CrystalReport1.SelectionFormula = SelectionFormula
    Frmmain.CrystalReport1.ProgressDialog = False
    Frmmain.CrystalReport1.Action = 1
      
     If PECanCloseEngine Then
        PECloseEngine
        PEOpenEngine
     End Ifyell(飞空草) ,我关了引擎,内存还是会涨,怎么办,怎么办!!
      

  17.   

    不好意思,我不在国内,手头没有crystal report8.0
    不过我找到一段代码
    是我做的日本项目的代码发给你
    重要步骤如下
    1.将CrystalReport的API函数要用到的两个模块文件
    添加到工程中
    2.用CrystalReport工具做一个报表文件(.RPT)
    重要函数如下
     
    PEOpenEngine打开引擎
    PEOpenPrintJob设定打印文件
    PESetNthTableLogOnInfo设定ODBC名
    PESetFormula设定报表文件参数值
    PEDiscardSavedData使报表文件重新取数据
    PEOutputToWindow报表文件以Window打开
    PEOutputToPrinter报表文件输出到打印机
    PEStartPrintJob打印报表
    PEClosePrintJob关闭打印文件
    PECloseEngine关闭引擎
     
    祝早日完工.
    ps:我发的SOURCE收到了吗
      

  18.   

    你的MAIL我受到了我回了一封给你
      

  19.   

    wangsitao(飞猪) :
      我收到了你的信,但还看不太懂,很多函数都要输入参数,
      不知道要输入些怎样的参数,
      还要多分析分析,
      谢谢!
      

  20.   

    我看了前面一些人的建议要你关闭引擎所以给出函数,但是否对于释放资源有帮助我不知道.
    另外我现在在CrystalReport6.0的应用中也遇到了一个问题:我的程序在windows98下一切正常,但到了win2kServer下却打印不了.具体表现为:打印机提示有一个文档待打印,但却没有文件在打印队列中.如何解决呢
      

  21.   

    回复人: yell(飞空草)  
        我也要用到打印,但我在WIN2000下没遇到你说得问题。
        不过我用的是8.0
      

  22.   


     研究了数天,我还是不会用你说的那些CrystalReport的API函数,
     不知道要输些什么参数进去,
     我知道这强人所难了,但我也被逼无奈,
     您能帮我把下面这些代码用CrystalReport的API函数翻译一下吗?
     不胜感激Frmmain.CrystalReport1.Destination = crptToFile
    Frmmain.CrystalReport1.PrintFileType = crptPagedText
     
    Frmmain.CrystalReport1.PrintFileName = App.Path & "\" & "temp\" & outfilename & ".txt"
    Frmmain.CrystalReport1.ReportFileName = App.Path & "\" & programname
    Frmmain.CrystalReport1.connect = connect
    Frmmain.CrystalReport1.SelectionFormula = SelectionFormula
    Frmmain.CrystalReport1.ProgressDialog = False
    Frmmain.CrystalReport1.Action = 1
      

  23.   

    在Microsoft Visual Basic 6.0中对数组元素数目的限制实际上是由数组下标的大小决定的。数组下标的大小不能超过32个二进制数位所能表示的数据(2147483648)。在实际使用过程中,应用程序将会首先占满内存。在Windows NT中单个进程只能占用4GB内存