i have a crystal report (version 9) that is already created and i want to view that report. do i need to reference anything? can someone point me in the right direction. i don't have any code yet, but i will try a few things right now.
Printable View
i have a crystal report (version 9) that is already created and i want to view that report. do i need to reference anything? can someone point me in the right direction. i don't have any code yet, but i will try a few things right now.
Create a reportdocument.
Add the report path to it (load).
put the datasource on a dataset and feed the reportdocumet with it (SetDataSource)
i'm using the express edition 2008. there is no reportdocument.
i'm using crystal reports 9. i'm pretty sure i need to add some references. i know i'm gonna need the cr viewer control but i don't know what else i need. i want to open an existing report and view it. that's the first step. then i will need to pass it a selection formula.
is it possible to use view a crystal report using Microsoft Visual Basic 2008 Express Edition?
ok. i added these two references:
Crystal Report Viewer Control 9
Crystal Reports 9 ActiveX Designer Run Time Libarary
and i added this component:
Crystal Report Viewer Control 9
here is my code:
vb.net Code:
Public Class frmReport Dim Appl As CRAXDRT.Application Dim Report As CRAXDRT.Report Private Sub frmReport_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Appl = New CRAXDRT.Application Report = New CRAXDRT.Report AxCRViewer91.DisplayBorder = False AxCRViewer91.DisplayTabs = False AxCRViewer91.EnableRefreshButton = False AxCRViewer91.EnableGroupTree = False AxCRViewer91.EnableSearchControl = False AxCRViewer91.EnableExportButton = True AxCRViewer91.Top = 0 AxCRViewer91.Left = 0 AxCRViewer91.Height = 14300 AxCRViewer91.Width = 19000 Report = Appl.OpenReport("J:\MDI2008\DPRequest.rpt") AxCRViewer91.ReportSource = Report AxCRViewer91.ViewReport() End Sub End Class
now i get this error:
AccessViolationException was unhandled
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
i removed the length and height. it seems that was causing the error. everything works great now.
vb.net Code:
Public Class frmReport Private Appl As New CRAXDRT.Application Private Report As New CRAXDRT.Report Private Sub frmReport_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load AxCRViewer91.DisplayBorder = False AxCRViewer91.DisplayTabs = False AxCRViewer91.EnableRefreshButton = False AxCRViewer91.EnableGroupTree = False AxCRViewer91.EnableSearchControl = False AxCRViewer91.EnableExportButton = True AxCRViewer91.Top = 0 AxCRViewer91.Left = 0 Report = Appl.OpenReport("J:\MDI2008\DPRequest.rpt") AxCRViewer91.ReportSource = Report AxCRViewer91.ViewReport() End Sub End Class
thanks for everyone's help. oh wait, i did it all myself. i'll give myself a pat on the back. i hope this will help somebody.
Hi Awesome Bezaman,
Thank you for your coding. I am having similar problem and I am trying it out your coding.
The coding with blue font is the error generator list below. Please Help me
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.shared
Imports CrystalDecisions.Windows.Forms
Public Class FrnTextCryReportViewer
Private Sub btnTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTest.Click
Try
Dim cryfolder As String = "F:\CustReportStorage\ CrystalReportOrderDetails.rpt"
Dim cryRpt As CrystalDecisions.CrystalReports.Engine.ReportDocument = New CrystalDecisions.CrystalReports.Engine.ReportDocument
cryRpt.Load(cryfolder)
With Me.AxCrystalActiveXReportViewer1
.ReportSource = cryRpt <--generate error "This value is Write-only"
.Refresh()
End With
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
End class
This is an example of the code I am using:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
Dim oApp = New CRAXDRT.Application
Dim oReport As CRAXDRT.Report
oReport = oApp.OpenReport("C:\temp\DR3076.R01.rpt", 1)
With oReport.Database.Tables(1).ConnectionProperties
.DeleteAll()
.Add("Provider", "SQLOLEDB.1")
.Add("User ID", "UserName")
.Add("Password", "Password")
.Add("Initial Catalog", "Database")
.Add("DSN", "DSNName")
End With
AxCrystalActiveXReportViewer1.ReportSource = oReport
AxCrystalActiveXReportViewer1.ViewReport()
End Sub
Private Sub AxCrystalActiveXReportViewer1_Enter(sender As System.Object, e As System.EventArgs) Handles AxCrystalActiveXReportViewer1.Enter
End Sub
End Class