Results 1 to 2 of 2

Thread: Looping through a ResultSet with ADO.NET

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2003
    Posts
    47

    Looping through a ResultSet with ADO.NET

    Hi,

    Simply trying to get a ResultSet and loop through it in ADO.NET. This is what I've got and it ain't working.


    Code:
           Dim dr As System.Data.OleDb.OleDbDataReader()
            Dim comm As New OleDb.OleDbCommand()
            comm.CommandText = "Select * from data2"
            comm.CommandType = CommandType.Text
            dr = comm.ExecuteReader(CommandBehavior.CloseConnection)
    
            Dim s As String
            s = ""
            While dr.read()
                MessageBox.Show(dr("id2").ToString())
            End While
            dr.close()

    I get an error with ExecuteReader saying:

    Value of type System.Data.OleDb.OleDbDataReader cannot be converted to a 1-dimensional array of type System.Data.OleDb.OleDbDataReader.


    Any idea what this problem is????

    Thanks!!

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    You declared dr as an array, probably removed a New statement in there. Remove the () at the end of the declaration.
    VB Code:
    1. Dim dr As System.Data.OleDb.OleDbDataReader'no parathesis

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width