Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2003
    Posts
    114

    Unanswered: Empty Recordset Error

    I am trying to run the following asp function:
    Code:
    Private Function GetAbs(dThisDate, lPartID)
    	sql_abs = "SELECT AbsCode FROM Absence WHERE AbsDate = '" & dThisDate & "' AND PartID = " & lPartID
    	Set rs_abs = conn.Execute(sql_abs)
    	GetAbs = rs_abs(0).Value
    	Set rs_abs = Nothing
    End Function
    It works fine if it finds a record but returns an error if it doesn't. How can I avoid this error?

    Thanks!

  2. #2
    Join Date
    Dec 2002
    Posts
    1,245
    Try:
    [code]
    Private Function GetAbs(dThisDate, lPartID)
    sql_abs = "SELECT AbsCode FROM Absence WHERE AbsDate = '" & dThisDate & "' AND PartID = " & lPartID
    Set rs_abs = conn.Execute(sql_abs)
    if rs_abs.EOF and rs_abs.BOF Then
    GetAbs = 0 ' or other value indicative of no result
    else
    GetAbs = rs_abs(0).Value
    end if
    Set rs_abs = Nothing
    End Function
    [code]
    Quote Originally Posted by Bobba Buoy
    I am trying to run the following asp function:
    Code:
    Private Function GetAbs(dThisDate, lPartID)
    	sql_abs = "SELECT AbsCode FROM Absence WHERE AbsDate = '" & dThisDate & "' AND PartID = " & lPartID
    	Set rs_abs = conn.Execute(sql_abs)
    	GetAbs = rs_abs(0).Value
    	Set rs_abs = Nothing
    End Function
    It works fine if it finds a record but returns an error if it doesn't. How can I avoid this error?

    Thanks!
    Have you hugged your backup today?

  3. #3
    Join Date
    Dec 2002
    Posts
    1,245
    ugh; sorry for the ugly posting. I forgot the / in the last [code] tag and now I can't edit the posting.

    Regards,

    hmscott
    Have you hugged your backup today?

Posting Permissions

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