jeffmoore64
Programmer
Hi,
I'm trying to get that good old "movelast" functionality with the datareader in vb.net. I understand that this is a forward only dataset. What I need is the last record in my retrieved data set and then the one prior to it etc. I can find no fuctionality in the datareader that will allow my to do this.
Any thoughts would be graet.
Jeff
Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
' Set up connection string
Dim ConnString As String = "Provider=IBMDA400;Data Source=JDEENT01; Default Collection=JRSLIB;User Id=xxxxx; Password=xxxxx;"
' Set up query string
Dim CmdString As String = "SELECT BFKLST FROM F55BOBFG"
'Declare Connection and DataReader variables
Dim Conn As OleDb.OleDbConnection = Nothing
Dim Reader As OleDb.OleDbDataReader = Nothing
Try
'Open Connection
Conn = New OleDb.OleDbConnection(ConnString)
Conn.Open()
'Execute Query
Dim Cmd As New OleDb.OleDbCommand(CmdString, Conn)
Reader = Cmd.ExecuteReader(CommandBehavior.SingleResult)
reader.
'Process The Result Set
While (Reader.Read())
===>
Console.WriteLine(Reader(0).ToString())
End While
Catch ex As Exception
Console.WriteLine("Error: {0}", ex)
Finally
'Close Connection
Reader.Close()
Conn.Close()
End Try
End Sub
I'm trying to get that good old "movelast" functionality with the datareader in vb.net. I understand that this is a forward only dataset. What I need is the last record in my retrieved data set and then the one prior to it etc. I can find no fuctionality in the datareader that will allow my to do this.
Any thoughts would be graet.
Jeff
Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
' Set up connection string
Dim ConnString As String = "Provider=IBMDA400;Data Source=JDEENT01; Default Collection=JRSLIB;User Id=xxxxx; Password=xxxxx;"
' Set up query string
Dim CmdString As String = "SELECT BFKLST FROM F55BOBFG"
'Declare Connection and DataReader variables
Dim Conn As OleDb.OleDbConnection = Nothing
Dim Reader As OleDb.OleDbDataReader = Nothing
Try
'Open Connection
Conn = New OleDb.OleDbConnection(ConnString)
Conn.Open()
'Execute Query
Dim Cmd As New OleDb.OleDbCommand(CmdString, Conn)
Reader = Cmd.ExecuteReader(CommandBehavior.SingleResult)
reader.
'Process The Result Set
While (Reader.Read())
===>
Console.WriteLine(Reader(0).ToString())
End While
Catch ex As Exception
Console.WriteLine("Error: {0}", ex)
Finally
'Close Connection
Reader.Close()
Conn.Close()
End Try
End Sub