标题:[求助]水晶报表
只看楼主
yangjun
Rank: 1
等 级:新手上路
帖 子:42
专家分:0
注 册:2006-7-31
 问题点数:0 回复次数:0 
[求助]水晶报表

各位高手:
我用的vs.net中自带的水晶报表,我是在vs 2002中的vb.net中进行设置的,但是点击打印报表时老是出现这个错误:未处理的(“CrystalDecisions.CrystalReports.Engine.LoadSaveReportException”类型的异常出现在 crystaldecisions.crystalreports.engine.dll 中

其他信息:加载报表失败。)

我的代码如下:Imports System.Collections
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.Windows.Forms
Imports System.Data
Imports System.Data.SqlClient
Public Class frmprint
Inherits System.Windows.Forms.Form
Private repname As String
Dim sql As String
'Private customerReport As ReportDocument

#Region " Windows 窗体设计器生成的代码 "

Public Sub New()
MyBase.New()

'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()

'在 InitializeComponent() 调用之后添加任何初始化

End Sub

'窗体重写处置以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer

'注意:以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents crvmain As CrystalDecisions.Windows.Forms.CrystalReportViewer
Friend WithEvents myrpd As CrystalDecisions.CrystalReports.Engine.ReportDocument
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.crvmain = New CrystalDecisions.Windows.Forms.CrystalReportViewer()
Me.myrpd = New CrystalDecisions.CrystalReports.Engine.ReportDocument()
Me.SuspendLayout()
'
'crvmain
'
Me.crvmain.ActiveViewIndex = -1
Me.crvmain.Dock = System.Windows.Forms.DockStyle.Fill
Me.crvmain.Name = "crvmain"
Me.crvmain.ReportSource = Nothing
Me.crvmain.Size = New System.Drawing.Size(292, 273)
Me.crvmain.TabIndex = 0
'
'myrpd
'
Me.myrpd.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.DefaultPaperOrientation
Me.myrpd.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.DefaultPaperSize
Me.myrpd.PrintOptions.PaperSource = CrystalDecisions.Shared.PaperSource.Upper
Me.myrpd.PrintOptions.PrinterDuplex = CrystalDecisions.Shared.PrinterDuplex.Default
'
'frmprint
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.crvmain})
Me.Name = "frmprint"
Me.Text = "打印报表"
Me.ResumeLayout(False)

End Sub

#End Region
Public Sub New(ByVal reportname As String, ByVal strsql As String)
MyBase.New()
InitializeComponent()
repname = reportname
sql = strsql
End Sub
Private Sub crvmain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim myobd As New mis_database.scmdb()
' Try
Dim myrpd As New ReportDocument()
Select Case repname
Case "storage"
myrpd.Load(Application.StartupPath & "mis_op\storage.rpt ")
Case "provider"
myrpd.Load(Application.StartupPath & "mis_op\providerReport.rpt")
Case "purchase"
myrpd.Load(Application.StartupPath & "mis_op\purchaseReport.rpt")
Case "draw"
myrpd.Load(Application.StartupPath & "mis_op\drawReport.rpt")
Case "reject"
myrpd.Load(Application.StartupPath & "mis_op\rejectReport.rpt")
End Select
Dim dp As New SqlDataAdapter()
Dim mydataset As New DataSet()
dp.Fill(mydataset, "myobd.CreateDataTableBySQL(sql)")
'myrpd.SetDataSource(myobd.CreateDataTableBySQL(sql))
myrpd.SetDataSource(mydataset)
Me.crvmain.ReportSource = myrpd
'Catch ex As Exception
' MsgBox("数据显示失败!失败原因:" & ex.Message, MsgBoxStyle.Exclamation)
' Me.Close()
' End Try
End Sub
End Class

搜索更多相关主题的帖子: 水晶 
2006-09-01 15:15



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-87425-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.090954 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved