Imports CrystalDecisions.CrystalReports.Engine
Protected Sub btnShowReport_Click(sender As Object, e As EventArgs) Handles btnShowReport.Click
Dim rpt As CrystalDecisions.CrystalReports.Engine.ReportDocument
rpt = New ReportDocument
rpt.Load(Server.MapPath("~\CrystalReport1.rpt"))
rpt.SetParameterValue("CustomerID", Me.txtSearch.Text)
Me.CrystalReportViewer1.ReportSource = rpt
End Sub
End Class
Dim objConn As New SqlConnection
Dim objCmd As New SqlCommand
Dim dtAdapter As New SqlDataAdapter
Dim ds As New DataSet
Dim dt As DataTable
Dim strConnString, strSQL As String
strConnString = "Server=localhost;UID=root;PASSWORD=;database=ชื่อฐานข้อมูล;Max Pool Size=400;Connect Timeout=600;"
strSQL = "SELECT * FROM member WHERE CustomerID = '" & Me.txtSearch.Text & "' "
objConn.ConnectionString = strConnString
With objCmd
.Connection = objConn
.CommandText = strSQL
.CommandType = CommandType.Text
End With
dtAdapter.SelectCommand = objCmd
dtAdapter.Fill(ds, "myDataTable")
dt = ds.Tables(0)
dtAdapter = Nothing
objConn.Close()
objConn = Nothing
Dim rpt As New ReportDocument()
Dim directory As String = My.Application.Info.DirectoryPath
rpt.Load(Server.MapPath("~\CrystalReport1.rpt"))
rpt.SetDataSource(dt)
Me.CrystalReportViewer1.ReportSource = rpt