01.
Imports
CrystalDecisions.CrystalReports.Engine
02.
Imports
System.Data.OleDb
03.
Public
Class
frmReport
04.
Private
Sub
btnReport_Click(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
btnReport.Click
05.
Dim
objConn
As
New
OleDbConnection
06.
Dim
objCmd
As
New
OleDbCommand
07.
Dim
dtAdapter
As
New
OleDbDataAdapter
08.
09.
Dim
ds
As
New
DataSet
10.
Dim
dt
As
DataTable
11.
Dim
strConnString, strSQL
As
String
12.
Dim
directory
As
String
= My.Application.Info.DirectoryPath
13.
14.
strConnString =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
& directory &
"\database.mdb;Jet OLEDB:Database Password=;"
15.
strSQL =
"SELECT * FROM audit WHERE CustomerID = '"
&
Me
.txtCustomerID.Text &
"' "
16.
17.
objConn.ConnectionString = strConnString
18.
With
objCmd
19.
.Connection = objConn
20.
.CommandText = strSQL
21.
.CommandType = CommandType.Text
22.
End
With
23.
dtAdapter.SelectCommand = objCmd
24.
25.
dtAdapter.Fill(ds,
"myDataTable"
)
26.
dt = ds.Tables(0)
27.
28.
dtAdapter =
Nothing
29.
objConn.Close()
30.
objConn =
Nothing
31.
32.
Dim
rpt
As
New
ReportDocument()
33.
Dim
directory
As
String
= My.Application.Info.DirectoryPath
34.
35.
rpt.Load(Server.MapPath(
"myCrystalReport1.rpt"
))
36.
rpt.SetDataSource(dt)
37.
Me
.CrystalReportViewer1.ReportSource = rpt
38.
Me
.CrystalReportViewer1.Refresh()
39.
40.
End
Sub
41.
42.
End
Class