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

End Class

I tried the above code. I have one Windows Form and a single Crystal report file (cr.rpt) in my project folder. I'm using Oracle 10G as the database. But I'm getting an error saying that "Logon Failed". ([Error Description]Image: http://pho.to/Zv6t)

Pls do help.

4

3 に答える 3

1

Finally found the solution from here

The only thing is, I need to set Database credentials at runtime for the Crystal Report to work fine.

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

This usual problem happens only to the Older version of CrystalReports caller from VB to .Net world.

Nothing to worry. Please use like this.........

connectionInfo.DatabaseName = "MahendrenDataBase"

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

connectionInfo.UserID = "UID";

connectionInfo.Password="Pwd"
于 2013-10-24T10:33:32.157 に答える
0

Imports CrystalDecisions.CrystalReports.Engine

Imports CrystalDecisions.Shared

Dim rpt As New RptCashbill

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