Private objRpt As New ReportDocument Protected Sub Page_PreInit(sender As Object, e As EventArgs) Handles Me.Load If IsPostBack = False Then 'objRpt.Load(Server.MapPath("~/Pending.rpt")) 'CrystalReportViewer1.ReportSource = objRpt Else ' objRpt = CType(Session("reportDocument"), ReportDocument) objRpt = Session("reportDocument") CrystalReportViewer1.ReportSource = objRpt End If End Sub Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim strConnString As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString Dim dat As String = TextBox1.Text Dim ds As New DataSet Dim cnn As SqlConnection Dim sql As String cnn = New SqlConnection(strConnString) cnn.Open() sql = "SELECT * from Pending_Entries where pen_dt=cast('" & dat & "'AS date)" Dim dscmd As New SqlDataAdapter(sql, cnn) dscmd.Fill(ds, "Product") ' MsgBox(ds.Tables(1).Rows.Count) cnn.Close() Dim objRpt As New ReportDocument objRpt.Load(Server.MapPath("~/Pending.rpt")) objRpt.SetDataSource(ds.Tables(1)) Session("reportDocument") = objRpt CrystalReportViewer1.ReportSource = objRpt CrystalReportViewer1.ToolPanelView = ToolPanelViewType.None CrystalReportViewer1.BestFitPage = False CrystalReportViewer1.Width = 900 CrystalReportViewer1.Height = 600 End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)