5
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports CrystalDecisions.Web
Imports CrystalDecisions.ReportSource
Imports CrystalDecisions.CrystalReports

Imports System.IO
Imports System.Net
Imports System.Net.Mail

Public Class Form1

Dim cryRpt As New ReportDocument

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    cryRpt.Load("C:\Documents and Settings\Prs1\My Documents\Visual Studio 2008\Projects\myCR\myCR\cr.rpt")
    CrystalReportViewer1.ReportSource = cryRpt

    CrystalReportViewer1.Refresh()

    Try
        Dim CrExportOptions As ExportOptions
        Dim CrDiskFileDestinationOptions As New  _
        DiskFileDestinationOptions()
        Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions()
        CrDiskFileDestinationOptions.DiskFileName = _
                                    "C:\crystalExport.pdf"
        CrExportOptions = cryRpt.ExportOptions
        With CrExportOptions
            .ExportDestinationType = ExportDestinationType.DiskFile
            .ExportFormatType = ExportFormatType.PortableDocFormat
            .DestinationOptions = CrDiskFileDestinationOptions
            .FormatOptions = CrFormatTypeOptions
        End With
        cryRpt.Export()
    Catch ex As Exception
        MsgBox(ex.ToString)
    End Try

End Sub

结束类

我试过上面的代码。我的项目文件夹中有一个 Windows 窗体和一个 Crystal 报告文件 (cr.rpt)。我使用 Oracle 10G 作为数据库。但我收到一条错误消息,提示“登录失败”。(【错误说明】图片: http: //pho.to/Zv6t

请帮忙。

4

3 回答 3

1

终于从这里找到了解决方案

唯一的事情是,我需要在运行时设置数据库凭据才能使 Crystal Report 正常工作。

cryRpt.SetDatabaseLogon("user", "password", "server", "database")
于 2013-01-16T08:47:57.840 回答
0

导入 CrystalDecisions.CrystalReports.Engine

导入 CrystalDecisions.Shared

Dim rpt 作为新的 RptCashbill

        ''''''fill Report data''''''
  CType(rpt,ReportDocument).ExportToDisk(ExportFormatType.PortableDocFormat,"C:/Report.pdf")
于 2014-03-12T09:55:43.597 回答
0

这个常见的问题只发生在从 VB 到 .Net 世界的旧版 CrystalReports 调用者身上。

没什么好担心的。请这样使用......

connectionInfo.DatabaseName = "MahendrenDataBase"

connectionInfo.ServerName ="SystemDSN";//Create a system dsn.

connectionInfo.UserID = "UID";

connectionInfo.Password="Pwd"
于 2013-10-24T10:33:32.157 回答