If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > why recordset object method FIND dont want to work ?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-21-04, 02:53
marconi8 marconi8 is offline
Registered User
 
Join Date: May 2003
Posts: 50
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
Reply With Quote
  #2 (permalink)  
Old 07-21-04, 21:03
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
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.
Reply With Quote
  #3 (permalink)  
Old 07-22-04, 01:56
marconi8 marconi8 is offline
Registered User
 
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
Reply With Quote
  #4 (permalink)  
Old 07-22-04, 02:01
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
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....
Reply With Quote
  #5 (permalink)  
Old 07-22-04, 07:56
marconi8 marconi8 is offline
Registered User
 
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
Reply With Quote
  #6 (permalink)  
Old 07-22-04, 09:55
gyuan gyuan is offline
Registered User
 
Join Date: Dec 2003
Posts: 454
change

rs.cursortype=adopenstatic

to

rs.cursortype=adOpenKeyset
Reply With Quote
  #7 (permalink)  
Old 07-22-04, 11:41
marconi8 marconi8 is offline
Registered User
 
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
Reply With Quote
  #8 (permalink)  
Old 07-22-04, 13:57
gyuan gyuan is offline
Registered User
 
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.
Reply With Quote
  #9 (permalink)  
Old 07-23-04, 19:58
marconi8 marconi8 is offline
Registered User
 
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..........
Reply With Quote
  #10 (permalink)  
Old 07-23-04, 20:59
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
see gyuan's reply above,.. you haven't included the constants file.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On