Results 1 to 10 of 10
  1. #1
    Join Date
    May 2003
    Posts
    50

    Unanswered: why recordset object method FIND dont want to work ?

    i have created record set object

    set rs = .........

    now i'am trying to find one record in the recordset

    rs.movefirst
    rs.find("field='value_to_search'",)


    when i use rs.find i get errors like - cannot scrool backward, cannot use parentheses when calling sub.

    what this errors are, and why described recordset method dont want to work., here is the fund method syntax from www tutorial www.w3schools.com

    objRecordset.Find(criteria,skiprows,direction,star t)

    people why can't make find method on recordset object, what i'am doing wrong ?

    thanks

  2. #2
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    Your recordset is being create using the wrong sort of cursor... you should be using a static cursor to open your recordset if you want to do finds on it and to be able to move forwards and backwards through your recordset.

  3. #3
    Join Date
    May 2003
    Posts
    50

    here is my code

    set db=server.createobject("adodb.connection")
    db.open "DSN=rsFIND;UID=SYSDBA;PWD=masterkey"

    set rsset=server.createobject("adodb.recordset")
    rsset.cursortype=adopenstatic
    rsset.open "select col1 from table1",db

    do until rsset.EOF
    response.write("value from problems table: "&rsset.fields("col1")&"<br/>")
    rsset.movenext
    loop


    rsset.find "col1=1"
    if rsset.EOF then
    response.write("Record not found")
    end if

    response.write(rsset.fields("col1"))
    ^^^^^----------
    this line i use to read record at which is positioned record after find
    ----------

    rsset.close
    set rsset=nothing

    db.close
    set db=nothing


    -----------
    using this code i get 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.


    what is wrong ?,

    thanks for helping

  4. #4
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    try this instead....
    Code:
    set db=server.createobject("adodb.connection")
    db.open "DSN=rsFIND;UID=SYSDBA;PWD=masterkey"
    
    set rsset=server.createobject("adodb.recordset") 
    rsset.cursortype=adopenstatic 
    rsset.open "select col1 from table1",db 
    
    do until rsset.EOF
      response.write("value from problems table: "&rsset.fields("col1")&"<br/>")
      rsset.movenext
    loop
    
    rsset.find "col1=1" 
    if rsset.EOF then
      response.write("Record not found")
    else
      response.write(rsset.fields("col1"))
    end if
    
    rsset.close
    set rsset=nothing 
    
    db.close
    set db=nothing
    I suspect you will always be EOF though....

  5. #5
    Join Date
    May 2003
    Posts
    50

    :(

    set db=server.createobject("adodb.connection")
    db.open "DSN=test;UID=SYSDBA;PWD=masterkey"

    set rs=server.createobject("adodb.recordset")
    rs.cursortype=adopenstatic
    rs.open "select * from TABLE_1",db


    rs.find "COL_1=1"

    if rs.EOF then
    response.write("record not found")
    else
    response.write(rs.fields("COL_1"))
    end if

    rs.close
    set rs=nothing

    db.close
    set db=nothing

    i still get error, cursortype is type by which i can scrool forward or backward.

    but i get error like
    Error Type:
    Microsoft OLE DB Provider for ODBC Drivers (0x80040E29)
    Rowset does not support scrolling backward.
    /marek/methodFind.asp, line 10

  6. #6
    Join Date
    Dec 2003
    Posts
    454
    change

    rs.cursortype=adopenstatic

    to

    rs.cursortype=adOpenKeyset

  7. #7
    Join Date
    May 2003
    Posts
    50

    i still get error

    set db=server.createobject("adodb.connection")
    db.open "test"

    set rs=server.createobject("adodb.recordset")
    rs.cursortype=adopenkeyset
    rs.open "select * from TABLE_1",db

    rs.find "COL_1=1"

    if rs.EOF then
    response.write("record not found")
    else
    response.write(rs.fields("COL_1"))
    end if

    rs.close
    set rs=nothing

    db.close
    set db=nothing

    error is -
    Error Type:
    Microsoft OLE DB Provider for ODBC Drivers (0x80040E29)
    Rowset does not support scrolling backward.
    /marek/methodFind2.asp, line 9


    where is the problem ?

    thank you for helping

  8. #8
    Join Date
    Dec 2003
    Posts
    454
    Did you include the file for ADO constants (like adovbs_Inc.asp)? If not you can add the code

    Const adOpenKeyset = 1

    before you open the recordset.

  9. #9
    Join Date
    May 2003
    Posts
    50

    i am realy mad

    people you know where was problem ????

    problem was that if i try to setup cursortype like that
    cursortype=adOpenStatic

    then it not work

    but if i type
    cursortype = 3

    then all is working,


    people why ????

    why using string value cursortype dont want to change, but when using integer value all is ok ????

    i feel realy shame on me, because i'am stuck with this stupid problem about some days..........

  10. #10
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    see gyuan's reply above,.. you haven't included the constants file.

Posting Permissions

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