DataTableReader Problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Help: I am trying to use a datatable reader to loop through a datatable but I
get the following error message when I try:

System.InvalidOperationException was unhandled
Message="DataTableReader is invalid for current DataTable
'CABG_Transfer_to_Raw'."
Source="System.Data"

This is the code to get the reader. I preview the CABG_Transfer_to_Raw
table and the data is shows up. Any ideas

Me.CABG_Transfer_to_RawTableAdapter.Fill(Me.HQIPatientLevelDataSet1.CABG_Transfer_to_Raw)
Dim dtreader1 As DataTableReader
dtreader1 =
Me.HQIPatientLevelDataSet1.CABG_Transfer_to_Raw.CreateDataReader
If dtreader1.HasRows = True Then
Do While dtreader1.Read
Dim Message As String = dtreader1("Diag_Code")
Dim Caption As String = dtreader1("Site")
Dim Buttons As MessageBoxButtons = MessageBoxButtons.YesNo

'Displays the MessageBox
Dim msbxResultDim As DialogResult
msbxResultDim = MessageBox.Show(Message, Caption, Buttons)
Loop
End If
This is what I get:
System.InvalidOperationException was unhandled
Message="DataTableReader is invalid for current DataTable
'CABG_Transfer_to_Raw'."
Source="System.Data"
 
Another problem also comes up
When I try to debug and I hit the line where the data is load into the
readed I get this message sometimes but not always "error: cannot obtain
value"
 
Back
Top