01.
Imports
System.Data.SqlClient
02.
Imports
CrystalDecisions.CrystalReports.Engine
03.
Imports
CrystalDecisions.
Shared
04.
Public
Class
WebForm1
05.
Inherits
System.Web.UI.Page
06.
07.
Protected
Sub
Page_Load(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
Me
.Load
08.
09.
End
Sub
10.
11.
Protected
Sub
Button1_Click(sender
As
Object
, e
As
EventArgs)
Handles
Button1.Click
12.
Dim
objConn
As
New
SqlConnection
13.
Dim
objCmd
As
New
SqlCommand
14.
Dim
dtAdapter
As
New
SqlDataAdapter
15.
16.
Dim
ds
As
New
DataSet
17.
Dim
dt
As
DataTable
18.
Dim
strConnString, strSQL
As
String
19.
20.
strConnString =
"Server= ... ;UID=sa;PASSWORD=....;database=....;Max Pool Size=400;Connect Timeout=600;"
21.
strSQL =
"SELECT * FROM vwReport WHERE Date BETWEEN '"
&
Me
.TextBox1.Text &
"' AND '"
&
Me
.TextBox2.Text &
"' "
22.
23.
objConn.ConnectionString = strConnString
24.
With
objCmd
25.
.Connection = objConn
26.
.CommandText = strSQL
27.
.CommandType = CommandType.Text
28.
End
With
29.
dtAdapter.SelectCommand = objCmd
30.
31.
dtAdapter.Fill(ds,
"myDataTable"
)
32.
dt = ds.Tables(0)
33.
34.
dtAdapter =
Nothing
35.
objConn.Close()
36.
objConn =
Nothing
37.
38.
Dim
rpt
As
New
ReportDocument()
39.
rpt.Load(Server.MapPath(
"CrystalReport1.rpt"
))
40.
rpt.SetDataSource(dt)
41.
Me
.CrystalReportViewer1.ReportSource = rpt
42.
Me
.CrystalReportViewer1.RefreshReport()
43.
End
Sub
44.
End
Class