Results 1 to 2 of 2

Thread: [RESOLVED] Newbie problem using executeReader

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2005
    Posts
    28

    [RESOLVED] Newbie problem using executeReader

    Firstly i am using VB2005 and MS Access 2002. Ok so I am using the executeReader to attempt to read all records between two sets of dates.

    However, i only appear to be getting one record. When i then try contactReader.nextResult, it returns false.

    I have double checked and there is definatly more than one record in that time frame. Im not sure if i am doing something incorrect since I am a newbie.

    Code:
    sql = "select * from dailyTable where recDate BETWEEN #" & startDate & "# AND #" & endDate & "#"
            Dim command As New OleDbCommand(sql, conn)
    
            conn.Open()
            Dim contactReader As OleDbDataReader = command.ExecuteReader()
            contactReader.Read()
            MsgBox(contactReader("grossSales").ToString, MsgBoxStyle.AbortRetryIgnore)
            MsgBox(contactReader.NextResult, MsgBoxStyle.Critical)
    
            conn.Close()
    The sql string comes together as:

    "select * from dailyTable where recDate BETWEEN #19/03/2007# AND #25/03/2007#"

    I know the date appears to be in the wrong format, i.e dd/mm instead of mm/dd, but this has not been a problem in the rest of my program.

    VB seems to convert it to this format when using SQL statements, since endDate =#3/25/2007# when not in the SQL statement.



    Many thanks in advance
    Last edited by 86cw86; Apr 11th, 2007 at 09:34 AM. Reason: Resolved

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Nov 2005
    Posts
    28

    Re: Newbie problem using executeReader

    I have resolved the problem now, I see i was attempting to use the dataset incorrectly.

    Using while (contactReader.read()) I can access all the records

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