Imports System.Data
Imports System.Data.OleDb
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.ReportSource
Imports CrystalDecisions.Windows.Forms
Imports CrystalDecisions.CrystalReports
Imports CrystalDecisions.CrystalReports.Engine.ReportDocument
Public Class clsReport
Inherits clsCommand
Public _SQL As String
Public _TableName As String
Public Function genDataSetToReport(ByVal prmRpt As ReportDocument) As ReportDocument
Dim oledbAdapter As OleDbDataAdapter
Dim ds As New DataSet
oledbAdapter = New OleDbDataAdapter(_SQL, connect())
oledbAdapter.FillSchema(ds, SchemaType.Source, _TableName)
oledbAdapter.Fill(ds, _TableName)
If ds.Tables(0).Rows.Count <> 0 Then
prmRpt.SetDataSource(ds)
Return prmRpt
Else
MessageBox.Show("ไม่พบข้อมูล")
End If
End Function ..ตรงนี้มันขึ้น warning
End Class
Code (VB.NET)
Public Class Form1
Private Sub loadForm() Handles MyBase.Load
CrystalReportViewer1.ToolPanelView = _
CrystalDecisions.Windows.Forms.ToolPanelViewType.None()
End Sub
Private Sub SongReport(ByVal prmField As String, ByVal prmValue As String)
With objclsReport
._SQL = "SELECT * FROM Customers "
._SQL += "where " & prmField
._SQL += " like ‘" & prmValue & "%’ "
._TableName = "song"
CrystalReportViewer1.ReportSource = .genDataSetToReport(New rptSong)
End With
End Sub
End Class