为什么突然得到错误加载报告faild与水晶报告? [英] Why suddenly got error load report faild with crystal report?

查看:74
本文介绍了为什么突然得到错误加载报告faild与水晶报告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的vb.net应用程序中尝试打印水晶报告时出现错误(加载报告fialed)但我的问题是(这个错误并不总是来,这突然来了在正确打印一些报告之后)可能在打印未知数量的报告之后,那么一次出现此错误。这是我的代码:



我尝试过:



< pre lang =vb> Dim cmd As New OleDbCommand
Dim connp As New OleDbConnection
Dim da As OleDbDataAdapter
Dim ds As DataSet
Dim strsql 作为 字符串
Dim strreprotname 作为 字符串
尝试
connp.Connection String = Provider = Microsoft.Jet.OLEDB.4.0;数据源=& Application.StartupPath& \ report.mdb; Jet OLEDB:数据库密码= KNOZ1003
connp.Open()
ds.Reset()
strsql = select * from tab3
cmd.CommandText = strsql
cmd.Connection = connp
da.SelectCommand = cmd
da.Fill(ds)
strreprotname = cashrpt
Dim strreportpath As String = Application.StartupPath& \Reports \& strreprotname& 。rpt
Dim rptdocument 作为 CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim prnset 作为 打印。 PrinterSettings
Dim pg As Printing.PageSettings
rptdocument.Load(strreportpath)
rptdocument.SetDataSource(ds.Tables( 0 ))
rptdocument.SetDatabaseLogon ( ,Application.StartupPath + \ report.mdb
prnset.PrinterName = cashprinter
rptdocument.PrintToPrinter (prnset,pg, False
cmd.Dispose()
connp.Close()
Catch ex As 异常
MessageBox.Show(ex.Message)
结束 尝试

解决方案

< blockquote>你没有关闭你的报告文件。

添加以下内容;

 rptdocument.Close()
rptdocument。 Dispose()



如果查看任务管理器,您可能会发现很多Crystal Reports实例正在运行。他们最终将自己关闭,但是当你完成它们时自己关闭它们会更好。


i got an error (Load report fialed) when trying to print crystal report in my vb.net application but my problem is (This error isn't always come, this suddenly comes after some reports printed correctly) maybe after print unknown number of reports, then one time this error comes. here is my code:

What I have tried:

Dim cmd As New OleDbCommand
    Dim connp As New OleDbConnection
    Dim da As New OleDbDataAdapter
    Dim ds As New DataSet
    Dim strsql As String
    Dim strreprotname As String
    Try
        connp.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Application.StartupPath & "\report.mdb; Jet OLEDB:Database Password=KNOZ1003"
        connp.Open()
        ds.Reset()
        strsql = "select * from tab3"
        cmd.CommandText = strsql
        cmd.Connection = connp
        da.SelectCommand = cmd
        da.Fill(ds)
        strreprotname = "cashrpt"
        Dim strreportpath As String = Application.StartupPath & "\Reports\" & strreprotname & ".rpt"
        Dim rptdocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument
        Dim prnset As New Printing.PrinterSettings
        Dim pg As New Printing.PageSettings
        rptdocument.Load(strreportpath)
        rptdocument.SetDataSource(ds.Tables(0))
        rptdocument.SetDatabaseLogon("", "", "", Application.StartupPath + "\report.mdb")
        prnset.PrinterName = cashprinter
        rptdocument.PrintToPrinter(prnset, pg, False)
        cmd.Dispose()
        connp.Close()
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try

解决方案

You are not closing off your Report Document.
Add the following;

rptdocument.Close()
rptdocument.Dispose()


If you have a look at Task Manager, you will likely find a lot of Crystal Reports instances running. They will eventually close themselves but it is much better practice to close them yourself when you are finished with them.


这篇关于为什么突然得到错误加载报告faild与水晶报告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆