Imports CrystalDecisions.CrystalReports.Engine
Imports System.Data.OleDb
Public Class frmReport
Private Sub btnReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReport.Click
Dim objConn As New OleDbConnection
Dim objCmd As New OleDbCommand
Dim dtAdapter As New OleDbDataAdapter
Dim ds As New DataSet
Dim dt As DataTable
Dim strConnString, strSQL As String
Dim directory As String = My.Application.Info.DirectoryPath
strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & directory & "\database.mdb;Jet OLEDB:Database Password=;"
strSQL = "SELECT * FROM audit WHERE CustomerID = '" & Me.txtCustomerID.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(directory & "\myCrystalReport1.rpt")
rpt.Load(Server.MapPath("myCrystalReport1.rpt"))
rpt.SetDataSource(dt)
Me.CrystalReportViewer1.ReportSource = rpt
Me.CrystalReportViewer1.Refresh()
End Sub
End Class