D
DaveS
Hi!
I am trying to create a DataReader in .Net 2003, retrieving data from an
Access backend db. In the code below, when I put a breakpoint within
the While...Read() loop, the datareader returns five records (which is
correct). However, when I simply run the program without the
breakpoint, only one record is being returned. Is there something I'm
missing???? The connection state is "Open", so I'm not sure why all
records aren't being returned.
Dim intUpdateEMGsCount As Integer = 0
Dim cnnUpdateEMGs As OleDbConnection = New
OleDbConnection(IMUX_Globals.connBE.ConnectionString)
Dim cmdUpdateEMGs As OleDbCommand = New OleDbCommand("SELECT " & _
"lngEMGId, " &
_
"IIf(IsNull([CountETB]),0, [CountETB]) AS TotalETB, " & _
"IIf(IsNull([CountEMRPS]),0, [CountEMRPS]) AS TotalEMRPS, " & _
"IIf(IsNull([CountRTT]),0, [CountRTT]) AS TotalRTT, " & _
"IIf(IsNull([CountDCH]),0, [CountDCH]) AS TotalDCH " & _
"FROM " & _
"(((tblOrig_EMG
LEFT JOIN qgrpCountETB ON tblOrig_EMG.strEMG = qgrpCountETB.strEMG) LEFT
JOIN qgrpCountDCH ON tblOrig_EMG.strEMG = qgrpCountDCH.strEMG) LEFT JOIN
qgrpCountEMRPS ON tblOrig_EMG.strEMG = qgrpCountEMRPS.strEMG) LEFT JOIN
qgrpCountRTT ON tblOrig_EMG.strEMG = qgrpCountRTT.strEMG", _
cnnUpdateEMGs)
cnnUpdateEMGs.Open()
odrUpdateEMGs =
cmdUpdateEMGs.ExecuteReader(CommandBehavior.CloseConnection)
Console.WriteLine("State: " & cnnUpdateEMGs.State.ToString)
If odrUpdateEMGs.HasRows Then
While odrUpdateEMGs.Read()
intNumRecs += 1
End While
End If
odrUpdateEMGs.Close()
Console.WriteLine("Num Records: " & intNumRecs.ToString)
TIA,
DaveS
I am trying to create a DataReader in .Net 2003, retrieving data from an
Access backend db. In the code below, when I put a breakpoint within
the While...Read() loop, the datareader returns five records (which is
correct). However, when I simply run the program without the
breakpoint, only one record is being returned. Is there something I'm
missing???? The connection state is "Open", so I'm not sure why all
records aren't being returned.
Dim intUpdateEMGsCount As Integer = 0
Dim cnnUpdateEMGs As OleDbConnection = New
OleDbConnection(IMUX_Globals.connBE.ConnectionString)
Dim cmdUpdateEMGs As OleDbCommand = New OleDbCommand("SELECT " & _
"lngEMGId, " &
_
"IIf(IsNull([CountETB]),0, [CountETB]) AS TotalETB, " & _
"IIf(IsNull([CountEMRPS]),0, [CountEMRPS]) AS TotalEMRPS, " & _
"IIf(IsNull([CountRTT]),0, [CountRTT]) AS TotalRTT, " & _
"IIf(IsNull([CountDCH]),0, [CountDCH]) AS TotalDCH " & _
"FROM " & _
"(((tblOrig_EMG
LEFT JOIN qgrpCountETB ON tblOrig_EMG.strEMG = qgrpCountETB.strEMG) LEFT
JOIN qgrpCountDCH ON tblOrig_EMG.strEMG = qgrpCountDCH.strEMG) LEFT JOIN
qgrpCountEMRPS ON tblOrig_EMG.strEMG = qgrpCountEMRPS.strEMG) LEFT JOIN
qgrpCountRTT ON tblOrig_EMG.strEMG = qgrpCountRTT.strEMG", _
cnnUpdateEMGs)
cnnUpdateEMGs.Open()
odrUpdateEMGs =
cmdUpdateEMGs.ExecuteReader(CommandBehavior.CloseConnection)
Console.WriteLine("State: " & cnnUpdateEMGs.State.ToString)
If odrUpdateEMGs.HasRows Then
While odrUpdateEMGs.Read()
intNumRecs += 1
End While
End If
odrUpdateEMGs.Close()
Console.WriteLine("Num Records: " & intNumRecs.ToString)
TIA,
DaveS