locked
Crystal report ,data set,form1,crystal report viewer ,coding RRS feed

  • Question

  • User-1729408034 posted

    I have added 1 crystal report named CrystalReport1.rpt
    I have added one form named form 1.
    I have also added DataSet.xsd.
    On form1 I have added 2 textboxes and one button and crystalreportviewer1.
    The user enters from date and to date in the respective textboxes then the user clicks on
    the button.
    So,the report of that from date to todate will be shown.
    The declarations are:
    Private dataadapter As SqlDataAdapter
    Dim str_com As String = "Data Source=COMPAQ\SQLEXPRESS;Initial
    Catalog=LibTry;Integrated Security=True"
    Dim objcon As SqlConnection
    Dim objcmd As SqlCommand
    Dim frmDate As DateTime
    Dim toDate As DateTime
    Dim rpt As New CrystalReport1()

    The code I wrote in the button is:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    Handles Button1.Click

    frmDate = Date.Parse(TextBox1.Text)
    toDate = Date.Parse(TextBox2.Text)
    call1(frmDate, toDate)


    Me.Close()

    End Sub

    The code for call function is:
    Private Sub call1(ByVal frmDate As Date, ByVal toDate As Date)
    Dim objcon As New SqlConnection("Data Source=COMPAQ\SQLEXPRESS;Initial
    Catalog=LibTry;Integrated Security=True")
    objcon.Open()
    Dim str_con As String = "select * from IssueMBA where ida between '" + frmDate +
    "' and ' " + toDate + "'"
    objcmd = New SqlCommand(str_con, objcon)
    Dim ds As New DataSet
    Dim dataadapter As New SqlDataAdapter(objcmd)
    dataadapter.Fill(ds)
    rpt.SetDataSource(ds)
    CrystalReportViewer1.ReportSource = rpt

    objcon.Close()
    End Sub
    The code of loaded form is:
    Private Sub issurepo_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
    Handles MyBase.Load
    objcon = New SqlConnection(str_com)
    End Sub


    I am not getting any errors but neither its executing after clicking on button.
    Kindly guide me.
    Thank You.

    Monday, May 14, 2012 3:18 AM

All replies

  • User-1312722619 posted

    you need to provide data source of report on report server. Dataset of your report should have something like this

    select * from IssueMBA where ida between @frmDate and @ToDate

    As you can see, you should have two parameters with type of DateTime. Run your report on report server and make sure it is running properly. Your WebForm is the place where you provide two parameters from textBoxes for your report and ReportViewer will render report.

    Thursday, May 17, 2012 9:35 AM