Berikut ini adalah cara menampilkan data di crystal report menggunakan vb.net
'Namespace
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports CrystalDecisions.Web
Imports System.Data
Imports System.Drawing.Printing
Imports System.Drawing
Imports System.IO
Imports System.Text
Imports System.Configuration.ConfigurationManager
'variable form merupakan letak file report di dalam aplikasi
private _path1 as string =Application.StartupPath & "\Laporan\"
'membuat fungsi untuk menampilkannya
Private sub ShowReport()
Dim rpt As New ReportDocument
Dim strReportPath As String = ""
'cetak faktur ini sudah didesign di crystal repornya dan query sudah ada di crystal report
strReportPath = _path1 & "cetakFaktur.rpt"
rpt.Load(strReportPath)
rpt.SetParameterValue("@id", "KB0001")
'untuk menampilkannya biasa crystal report mengeluarkan form logon, agar tidak keluar maka kita buat logon di coding sebagai refreshnya
Dim server, database, user, password As String
Dim db As New System.Data.Common.DbConnectionStringBuilder
With db
.ConnectionString = ConnectionStrings("Data").ConnectionString
server = CType(.Item("Server"), String)
database = CType(.Item("Database"), String)
user = CType(.Item("Uid"), String)
password = CType(.Item("Pwd"), String)
End With
If password Is Nothing Then
For Each cn As IConnectionInfo In rpt.DataSourceConnections
cn.SetConnection(server, database, True)
Next
Else
For Each cn As IConnectionInfo In rpt.DataSourceConnections
cn.SetConnection(server, database, user, password)
Next
End If
'datacrystal merupakan nama crystal report viewer, kamu harus mengedraknya ke form
DataCrystal.ReportSource = rpt
DataCrystal.Show()
End sub
Sekian terima kasih
semoga bermanfaat
'Namespace
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports CrystalDecisions.Web
Imports System.Data
Imports System.Drawing.Printing
Imports System.Drawing
Imports System.IO
Imports System.Text
Imports System.Configuration.ConfigurationManager
'variable form merupakan letak file report di dalam aplikasi
private _path1 as string =Application.StartupPath & "\Laporan\"
'membuat fungsi untuk menampilkannya
Private sub ShowReport()
Dim rpt As New ReportDocument
Dim strReportPath As String = ""
'cetak faktur ini sudah didesign di crystal repornya dan query sudah ada di crystal report
strReportPath = _path1 & "cetakFaktur.rpt"
rpt.Load(strReportPath)
rpt.SetParameterValue("@id", "KB0001")
'untuk menampilkannya biasa crystal report mengeluarkan form logon, agar tidak keluar maka kita buat logon di coding sebagai refreshnya
Dim server, database, user, password As String
Dim db As New System.Data.Common.DbConnectionStringBuilder
With db
.ConnectionString = ConnectionStrings("Data").ConnectionString
server = CType(.Item("Server"), String)
database = CType(.Item("Database"), String)
user = CType(.Item("Uid"), String)
password = CType(.Item("Pwd"), String)
End With
If password Is Nothing Then
For Each cn As IConnectionInfo In rpt.DataSourceConnections
cn.SetConnection(server, database, True)
Next
Else
For Each cn As IConnectionInfo In rpt.DataSourceConnections
cn.SetConnection(server, database, user, password)
Next
End If
'datacrystal merupakan nama crystal report viewer, kamu harus mengedraknya ke form
DataCrystal.ReportSource = rpt
DataCrystal.Show()
End sub
Sekian terima kasih
semoga bermanfaat
Post a Comment for "Menampilkan Data Crystal Report Menggunakan VB.net"