Professional Web Applications Themes

SQL Error - not retrieving any record - ASP Database

I am getting the following error: Error Type: ADODB.Field (0x80020009) Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record. /sds-test/admin.asp Here is the code: sqlString = "SELECT current_weekday, " &_ "current_open_time, current_close_time FROM current_hours " &_ " WHERE current_date = " & (Date) SET RS = Con.Execute( sqlString ) I am on Windows XP, using Access 2000 and IIS. I have accessed this record using another "WHERE" statement and then compared "current_date" and "(Date)". These values are equal with no leading or trailing blanks. There is something wrong with the ...

  1. #1

    Default SQL Error - not retrieving any record

    I am getting the following error:

    Error Type:
    ADODB.Field (0x80020009)
    Either BOF or EOF is True, or the current record has been deleted. Requested
    operation requires a current record.
    /sds-test/admin.asp

    Here is the code:

    sqlString = "SELECT current_weekday, " &_
    "current_open_time, current_close_time FROM current_hours " &_
    " WHERE current_date = " & (Date)
    SET RS = Con.Execute( sqlString )

    I am on Windows XP, using Access 2000 and IIS. I have accessed this record
    using another "WHERE" statement and then compared "current_date" and
    "(Date)". These values are equal with no leading or trailing blanks. There
    is something wrong with the "WHERE" statement, but I don't know what. Any
    suggestions?


    Guest

  2. #2

    Default Re: SQL Error - not retrieving any record

    Hi westernnord,

    That error indicates that you're executing a query to bring back records in
    a recordset, but no records matched the criteria of your query. So, the
    recordset it empty. If a recordset is empty, you cannot pull any values
    from it. If you do, you'll get the error that you included.

    Set RS = Con.Execute(sqlString)
    If Not RS.EOF Then
    '''your code
    Else
    Response.Write "There are no records matching this query.<br>" &
    sqlString
    End If


    If you feel that there should be records returned, you probably aren't
    getting any because the query that you're sending to the database looks like
    this:

    "SELECT current_weekday, current_open_time, current_close_time FROM
    current_hours WHERE current_date = 10/17/2004"

    10/17/2004 is 10 divided by 17 divided by 2004. Dates need to be delimited.
    At a minimum, change your query building to look like this:

    "SELECT current_weekday, " &_
    "current_open_time, current_close_time FROM current_hours " &_
    " WHERE current_date = #" & (Date) & "#"

    But then read this to see the "right" way of dealing with dates.
    http://www.aspfaq.com/show.asp?id=2023

    Ray at home



    <net> wrote in message
    news:phx.gbl... 


    Ray Guest

  3. #3

    Default Re: SQL Error - not retrieving any record

    Fabulous Ray... That is a great article and your solution worked fine.

    "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
    message news:%23X4%phx.gbl... 
    >
    >[/ref]


    Guest

Similar Threads

  1. retrieving last record inserted using IDENTITY - ASPJScript
    By Fabiano Arruda in forum Dreamweaver AppDev
    Replies: 4
    Last Post: May 11th, 05:54 PM
  2. retrieving individual record
    By pat luton in forum Dreamweaver AppDev
    Replies: 1
    Last Post: April 8th, 01:39 PM
  3. Data Query - Error Retrieving Tables
    By Hung Kuen Kung Fu in forum Dreamweaver AppDev
    Replies: 2
    Last Post: March 24th, 03:39 PM
  4. Retrieving a field from the NEW record
    By Eric E in forum PostgreSQL / PGSQL
    Replies: 3
    Last Post: January 19th, 04:54 PM
  5. Database record retrieving
    By Atrax in forum ASP
    Replies: 0
    Last Post: June 30th, 02:58 AM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139