Private Sub PreviewReport(Optional ByVal IsPrint As Boolean = False)
Dim Mydb As New MYSQL
Dim ds As New DataSet
Dim rpt As New ReportDocument()
Dim strsql As String
Dim DT As DataTable
Dim xFile2 As String = Server.MapPath("CrystalReport3.rpt")
rpt.Load(xFile2, OpenReportMethod.OpenReportByDefault)
strsql = "select * from View_1"
DT = Mydb.GetDataTable(strsql)
strsql = "select * from View_2"
DT = Mydb.GetDataTable(strsql)
strsql = "select * from View_4"
DT = Mydb.GetDataTable(strsql)
'Response.Write(strsql)
ds.Tables.Add(DT)
ds.Tables(0).TableName = "TestTable"
rpt.Database.Tables(0).SetDataSource(ds.Tables(0))
Dim L1 As TableLogOnInfo = rpt.Database.Tables(0).LogOnInfo
L1.ConnectionInfo.Password = "****"
L1.ConnectionInfo.ServerName = "***.***.*.***"
L1.ConnectionInfo.UserID = "admins"
rpt.SetParameterValue("mounthst", DropDownList2.Text)
rpt.SetParameterValue("mounthen", DropDownList3.Text)
rpt.SetParameterValue("yearst", txtyear.Text)
rpt.SetParameterValue("yearen", txtyear.Text)
CrystalReportViewer1.ReportSource = rpt
CrystalReportViewer1.DataBind()
Session("ReportSource1") = rpt
End Sub
Private Sub page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
Try
If IsPostBack Then
If Session("ReportSource1").ToString() IsNot Nothing Then
CrystalReportViewer1.ReportSource = Session("ReportSource1")
End If
End If
Catch ex As Exception
'Response.Write(ex.Message.ToString())
End Try
End Sub