Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. executereader inquiry

executereader inquiry

Scheduled Pinned Locked Moved Visual Basic
question
10 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    maytel
    wrote on last edited by
    #1

    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

    D 1 Reply Last reply
    0
    • M maytel

      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

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      "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

      M 1 Reply Last reply
      0
      • D Dave Kreskowiak

        "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

        M Offline
        M Offline
        maytel
        wrote on last edited by
        #3

        i was only wondering if it could be done since there is "item" in executereader ty

        D 1 Reply Last reply
        0
        • M maytel

          i was only wondering if it could be done since there is "item" in executereader ty

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          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

          M 1 Reply Last reply
          0
          • D Dave Kreskowiak

            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

            M Offline
            M Offline
            maytel
            wrote on last edited by
            #5

            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

            D 1 Reply Last reply
            0
            • M maytel

              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

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              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

              M 1 Reply Last reply
              0
              • D Dave Kreskowiak

                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

                M Offline
                M Offline
                maytel
                wrote on last edited by
                #7

                honestly nothing im only experimenting on the "item" i found in datareader

                D 1 Reply Last reply
                0
                • M maytel

                  honestly nothing im only experimenting on the "item" i found in datareader

                  D Offline
                  D Offline
                  Dave Kreskowiak
                  wrote on last edited by
                  #8

                  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 Sub

                  RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                  M 1 Reply Last reply
                  0
                  • D Dave Kreskowiak

                    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 Sub

                    RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                    M Offline
                    M Offline
                    maytel
                    wrote on last edited by
                    #9

                    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

                    D 1 Reply Last reply
                    0
                    • M maytel

                      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

                      D Offline
                      D Offline
                      Dave Kreskowiak
                      wrote on last edited by
                      #10

                      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

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups