Add CrystalDecisions references to your project and drag the ReportViewer control onto your form.
CrystalDecisions.CrystalReports.Engine
CrystalDecisions.Shared
CrystalDecisions.Windows.Forms
CrystalDecisions.ReportSource
'----Create a DataTable containing the data for the report:
Imports System.Data.OleDb
Dim strConnection As String = "..."
Dim Connection As New OleDbConnection(strConnection)
Dim strSQL As String = "Select * From Employee"
Dim DA As New OleDbDataAdapter(strSQL, Connection)
Dim DS As New DataSet
DA.Fill(DS, "Employee")
'----Verify the path to the Crystal Report's .RPT file:
Dim strReportPath As String = Application.StartupPath & _
"\" & strReportName & ".rpt"
If Not IO.File.Exists(strReportPath) Then
Throw (New Exception("Unable to find crystal report file:" & _
vbCrLf & strReportPath))
End If
'----Load the Crystal report's .RPT file and pass in the DataTable:
Dim cr As New ReportDocument
cr.Load(strReportPath)
cr.SetDataSource(DS.Tables("Employee"))
'-----Set the CrystalReportViewer's appearance and set the ReportSource:
CrystalReportViewer.ShowRefreshButton = False
CrystalReportViewer.ShowCloseButton = False
CrystalReportViewer.ShowGroupTreeButton = False
CrystalReportViewer.ReportSource = cr
'------Loading a report when the report's DataSource is a .NET DLL
Dim strReportPath As String = Application.StartupPath & "\" & _
strReportName & ".rpt"
If Not IO.File.Exists(strReportPath) Then
Throw (New Exception("Unable to locate report file:" & _
vbCrLf & strReportPath))
End If
'---Load the Crystal report's .RPT file:
Dim cr As New ReportDocument
cr.Load(strReportPath)
'---Set the CrystalReportViewer's appearance and set the ReportSource:
CrystalReportViewer.ShowRefreshButton = False
CrystalReportViewer.ShowCloseButton = False
CrystalReportViewer.ShowGroupTreeButton = False
CrystalReportViewer.ReportSource = cr
4 comments:
Hey keep posting such smart and important articles.
Welcome to Trendy Mixup, your one-stop destination for the latest trends in fashion, lifestyle, beauty, and beyond. Explore a curated collection of stylish clothing, accessories, and home essentials that blend chic designs with affordability. Whether you're seeking wardrobe inspiration, home decor ideas, or simply looking to stay updated with the hottest trends, Trendy Mixup has you covered. Join our vibrant community of trendsetters and elevate your style game with our diverse range of products and insightful content. Stay ahead of the curve and embrace the essence of modern living with Trendy Mixup – where trendiness meets variety!
Active Detailing is the best car detailing franchise in India, renowned for its exceptional quality and comprehensive services.
Post a Comment