TableAdapter Question RRS feed

  • Question

  • I have a form with two textbox controls; they are used to gather values for StartDate and EndDate parameters of an SQL Server stored procedure. I used the designer to build a data source from the stored procedure, and have GetDataBy(@StartDate, @EndDate) as a query in the table adapter. I use a button click to run the query and return the results to a local report, Report1.rdlc.


    My problem is that the report only displays 1 row, the very last row in the set of rows returned if you were to preview the data by the same parameter values. I do not have a First or Last expression on the report control for any fields.


    Can someone point me in a direction to chase this down?


    My code is below:


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim txtStartDate As Date
            Dim txtEndDate As Date

            txtStartDate = Date.Parse(TextBox1.Text.Trim)
            txtEndDate = Date.Parse(TextBox2.Text.Trim)

            Dim paramInfo As ReportParameterInfoCollection
            Dim paramList As New Generic.List(Of ReportParameter)

            paramList.Add(New ReportParameter("StartDate", txtStartDate, False))
            paramList.Add(New ReportParameter("EndDate", txtEndDate, False))

            paramInfo = ReportViewer1.LocalReport.GetParameters()

            Me.UspGetByDateTableAdapter.GetDataBy(txtStartDate, txtEndDate)


        End Sub


    SQL Profiler shows that the value is being input into the stored procedure with a pair of single quotes around the data value put into the parameter. Example: @EndDate=''2007-07-30 00:00:00:000''. I know you cannot run this syntax through Query Analyzer, so I do not know if this is the problem I have; I do not believe so, since the report does return at least one row.


    I'm stumped.... please help.

    Thursday, August 2, 2007 2:35 AM