I am sure I must be missing something simple here, but I can't seem to user an ado.net datareader with reporting. Here is a code sample:
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,
David
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)
cn.Open()
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)
cmd.Parameters.Add(p1)
cmd.Parameters.Add(p2)
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,
David