This is a migrated thread and some comments may be shown as answers.

Using's ExecuteReader in throws error " Invalid attempt to read when no data is present." -- ???

1 Answer 14 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
David asked on 09 May 2013, 06:59 PM
I am sure I must be missing something simple here, but I can't seem to user an datareader with reporting. Here is a code sample:

Private Sub RptRadIdleTime_NeedDataSource(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.NeedDataSource
        rptHeaderBox.Value = "Report Criteria:" & vbCrLf & "Date Range: " & StartDate.ToShortDateString & " to " & EndDate.ToShortDateString & vbCrLf & _
        "Employee: " & EmployeeName & vbCrLf
        Dim cn As New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
        Dim cmd As New SqlCommand("ReportIdleTime")
        cmd.CommandType = CommandType.StoredProcedure
        cmd.Connection = cn
        cmd.Parameters.Add(New SqlParameter("EmployeeID", EmployeeID))
        Dim p1 As New SqlParameter("Start", SqlDbType.DateTime)
        p1.Value = CDate(StartDate)
        Dim p2 As New SqlParameter("End", SqlDbType.DateTime)
        p2.Value = CDate(EndDate)
        Me.DataSource = cmd.ExecuteReader
    End Sub

This yields the following error:

An error has occurred while processing TextBox 'TextBox6': Invalid attempt to read when no data is present.

(And the same error on every other field.)

The same method of connecting works fine with linq-to-sql.

Thanks for any help,


1 Answer, 1 is accepted

Sort by
Telerik team
answered on 14 May 2013, 03:59 PM

We have reproduced the exception and will take the necessary steps to fix the problem. Meanwhile our suggestion is to use SqlDataSource component instead of a SqlCommand or an ObjectDataSource component with a business object which wraps the reader as shown in the help article.

the Telerik team

Have you tried the new visualization options in Telerik Reporting Q1 2013? You can get them from your account.

General Discussions
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question