Problem with SQL query

Results 1 to 3 of 3

Thread: Problem with SQL query

  1. #1
    Matthew Kirwan Guest

    Default Problem with SQL query

    Hi, I am getting the following error in my ASP page<BR><BR>ADODB.Field error &#039;80020009&#039; <BR><BR>Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record. <BR>? <BR><BR>and I have identified that there is an error in the following code segment:<BR><BR><BR>&#060;%<BR> startDate = dateSerial(startYear, startMonth - 1, 1)<BR> <BR> strSQL = "SELECT * FROM Reports " _<BR> & "WHERE ReportStartDate = #" & startDate &"#" <BR> <BR> &#039; Create a recordset object instance, and execute the SQL statement<BR><BR> Set objRS = Server.CreateObject("ADODB.Recordset")<BR> ObjRS.Open strSQL, objConn, adOpenKeyset, adLockPessimistic<BR>%&#062;<BR><BR>Does anyone know what I am doing wrong?<BR><BR>My guess is that either the syntax of the SQL statement is wrong<BR>and/or I am having a problem because I may be using a different date format in my script compared with my Access database. The dateSerial function produces a date of the format dd/mm/yy whereas Access is storing the date as dd/mm/yyyy (Short Date format). Maybe the script can&#039;t match 2/2/01 (product of DateSerial function) with 2/02/2001 (date as stored in database) ?<BR><BR>Regards,<BR><BR>Matthew

  2. #2
    Join Date
    Dec 1969

    Default there's no record returned...

    this happens to me constantly, and i&#039;m always reminded to just perform a count query using the same "WHERE" clause and just use an if statement for that...hope this helps!

  3. #3 Guest

    Default RE: Problem with SQL query

    Ender&#039;s advice is good, but you should also display your SQL command to see just what you have:<BR><BR>strSQL = "SELECT * FROM Reports " _<BR>& "WHERE ReportStartDate = #" & startDate &"#" <BR>Response.Write "&#060;hr&#062;" & strSQL & "&#060;hr&#062;" <BR><BR>If it looks ok then copy an paste it into your access db and see what you get.<BR><BR>If youa are not in USA, you may have to use LCID (locality id) and/or the CDate funtion, so that your SQL would be like this:<BR>Session.LCID = YourLocalID<BR>strSQL = "SELECT * FROM Reports " _<BR>& "WHERE ReportStartDate = #" & CDate(startDate) &"#" <BR>

Posting Permissions

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