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
End ClassWie programmatisch
Ich habe versucht, den obigen Code Crystal Report als PDF in VB.NET zu exportieren. Ich habe ein Windows Form und eine einzelne Crystal Report-Datei (cr.rpt) in meinem Projektordner. Ich verwende Oracle 10G als Datenbank. Aber ich bekomme einen Fehler, der "Logon Failed" sagt. ([Fehlerbeschreibung] Bild: http://pho.to/Zv6t)
Pls helfen.
Diese liegt wahrscheinlich daran, dass Sie dem Bericht nicht mitgeteilt haben, welche Anmeldeinformationen für die Verbindung zur Datenbank erforderlich sind. Sie legen sie für das Design des Berichts als Entwurf fest, aber Sie müssen den Bericht zur Laufzeit erneut melden. –
@ Ciarán Können Sie mir sagen, wo ich die Anmeldedaten einstellen soll? Ich bin neu in VB.NET und Crystal Reports. Und auch jedes Codebeispiel, das in Runtime gesetzt werden soll? –
Danke euch. Gefunden die Lösung von [hier] (http://stackoverflow.com/questions/12486925/crystal-reports-how-to-set-database-credentials) –