executereader inquiry
-
this doesnt work is it possible to to make this work? Dim oleCmd As New OleDbCommand("SELECT RecNum " & _ "FROM Serial_Table", oleCon) With oleCmd lRecNum = .ExecuteReader.Item("RecNum").ToString End With tnx in advance
"This doesn't work" isn't a good explanation of the problem. What's it doing/not doing?? What are you expecting the code to do? Also, there not enough of the code to "get it to work" or diagnose the problem. What is
lRecNum
defined as? What are you trying to do with the data? About the only thing we could do is rewrite it and guess what you're trying to get it to do.Dim oleDbConn As New OleDbConnection(connectionString
Dim oleDbComm As New OleDbCommand("SELECT RecNum FROM Serial_Table", oleConn)
Dim oleDbReader As OleDbDataReader
oleDbReader = oleDbComm.ExecuteReader()
While oleDbReader.Read() = True
' What are you doing with this data??????
_...something..._oleDbReader.GetInt32(0)
End While
oleDbReader.Close()
oleDbConn.Close()RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome -- modified at 22:22 Friday 17th February, 2006
-
"This doesn't work" isn't a good explanation of the problem. What's it doing/not doing?? What are you expecting the code to do? Also, there not enough of the code to "get it to work" or diagnose the problem. What is
lRecNum
defined as? What are you trying to do with the data? About the only thing we could do is rewrite it and guess what you're trying to get it to do.Dim oleDbConn As New OleDbConnection(connectionString
Dim oleDbComm As New OleDbCommand("SELECT RecNum FROM Serial_Table", oleConn)
Dim oleDbReader As OleDbDataReader
oleDbReader = oleDbComm.ExecuteReader()
While oleDbReader.Read() = True
' What are you doing with this data??????
_...something..._oleDbReader.GetInt32(0)
End While
oleDbReader.Close()
oleDbConn.Close()RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome -- modified at 22:22 Friday 17th February, 2006
-
If WHAT could be done? You still haven't explained what your trying to do... RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
If WHAT could be done? You still haven't explained what your trying to do... RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
rephrase: is it possible to retrieve a data without using a datareader? (aside from executescalar) is was wondering coz i saw "Item" in executereader Dim oleCmd As New OleDbCommand("SELECT FldName " & _ "FROM TableName", oleCon) With oleCmd variable = .ExecuteReader.Item("FldName").ToString End With tnx in advance -- modified at 20:46 Sunday 19th February, 2006
-
rephrase: is it possible to retrieve a data without using a datareader? (aside from executescalar) is was wondering coz i saw "Item" in executereader Dim oleCmd As New OleDbCommand("SELECT FldName " & _ "FROM TableName", oleCon) With oleCmd variable = .ExecuteReader.Item("FldName").ToString End With tnx in advance -- modified at 20:46 Sunday 19th February, 2006
There are many ways to read a recordset. But, I'm repeating myself....What are you trying to do with this data???????? This will have a large impact on how you read it!!!! RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
There are many ways to read a recordset. But, I'm repeating myself....What are you trying to do with this data???????? This will have a large impact on how you read it!!!! RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
WHY DIDN'T YOU SAY THIS IN YOUR FIRST POST?!?!?!?!
Private Sub Button2_Click(blah, blah) Handles Button2.Click
Dim conn As New OleDbConnection("connectionString")
Dim comm As New OleDbCommand("SELECT * FROM MyTable", conn)
Dim dr As OleDbDataReader
conn.Open()
dr = comm.ExecuteReader(CommandBehavior.CloseConnection)
Dim ID As Integer
While dr.Read()
ID = dr.Item("TableColumnName")
End While
dr.Close()
End SubRageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
WHY DIDN'T YOU SAY THIS IN YOUR FIRST POST?!?!?!?!
Private Sub Button2_Click(blah, blah) Handles Button2.Click
Dim conn As New OleDbConnection("connectionString")
Dim comm As New OleDbCommand("SELECT * FROM MyTable", conn)
Dim dr As OleDbDataReader
conn.Open()
dr = comm.ExecuteReader(CommandBehavior.CloseConnection)
Dim ID As Integer
While dr.Read()
ID = dr.Item("TableColumnName")
End While
dr.Close()
End SubRageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
coz i didn't see it relevant need not shout though asking nicely question wasnt still answered might not be possible to to use the "item" in executereader without using datareader in retreiving data variable = executereader.item("fldname") tnx anyway
It works. I just showed you how to use it. You saw the Item property come up because the ExecuteReader method returns an OleDbDataReader object, which is the thing exposing the Item property. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome