PDA

View Full Version : Bookmark property


ScottInTexas
08-09-2003, 03:58 PM
I am trying to set the bookmark on a recordset from a session variable that was previously saved or unset.


Set RS=Server.CreateObject("ADODB.recordset")
RS.CursorType=adOpenDynamic
RS.Open SQL, cnxn
response.write("opened recordset<br>")
RS.MoveLast
RS.MoveFirst
If session("bkmk") <> "" Then
response.write("BkMark=" & session("bkmk") & "<br>")
RS.Bookmark=session("bkmk")
Else
response.write("Setting bkmk<br>")
session("bkmk")=1
End If


Here is my debugging results and the error.

Form submitted Jobs
opened recordset
BkMark=1

ADODB.Recordset error '800a0bb9'

The application is using arguments that are of the wrong type, are out of acceptable range, or are in conflict with one another.

/GetData.asp, line 37

Thanks for looking.

raf
08-10-2003, 12:06 PM
As far as i know, you can only set bookmarks with a keyset or static recordset.
So your cursortype needs to be 1 or 3.
You got a dynamic cursortype (2)

ScottInTexas
08-10-2003, 06:14 PM
Thanks Raf,

I read that this morning but also read that if I opened a recordset on an access database with a type 2 cursor that it would default to a type1. I'll force the type and forget default and let you know what happens.

ScottInTexas
08-10-2003, 07:39 PM
OK,

Are the bookmarks a permanent part of the database table? I mean the bookmarks aren't created when the recordset opens are they?

All I am trying to do is save the bookmark of the current record in the recordset. When the user clicks on Next, Previous, whatever the recordset is opened, the bookmark is set from the previously saved bookmark session variable, then the method is invoked and the new bookmark is saved.

Why is this so difficult? It's not like I am doing anything weird!


If request.querystring("Type")="Table" then
tbl=Request.querystring("cmnd")
SQL="SELECT * FROM " & tbl
session("curtbl")=tbl
session("recNum")=""
Else
SQL="SELECT * FROM " & session("curtbl")
response.write("SettingSQL<br>")
End If

Set RS=Server.CreateObject("ADODB.recordset")

RS.Open SQL, cnxn, adOpenKeyset, adLockOptimistic

If session("recNum") <> "" Then
response.write("First Bookmark=" & session("recNum") & "<br>")
RS.Bookmark=session("recNum")
End If

response.write("Command " & request.querystring("cmnd") & "<br>")

Select Case Request.querystring("cmnd")
Case "Next"
response.write("Moving recID=" & RS.Fields(1).Value & "<br>")
RS.MoveNext
If RS.EOF Then
response.write("EOF<br>")
RS.MoveLast
isEOF=True
err.clear
Else
response.write("Not EOF<br>")
isEOF=False
End If
response.write("Now at RecID=" & RS.Fields(1).Value & "<br>")
session("recNum")=RS.Bookmark
response.write("Bookmark=" & RS.Bookmark & "<br>")

End Select
Call displayDoc



Any suggestions or am I going about it all wrong? Maybe I should use the rec ID instead of the bookmark, do a find and then move from there?

raf
08-10-2003, 07:59 PM
ah, so it's recordset paging you're after.

if you run a search on google or so for "ASP recordset paging" you'll get loads of example scripts and tutorials like this one
http://www.aspalliance.com/brettb/EasyADORecordSetPaging.asp

ScottInTexas
08-10-2003, 08:12 PM
Thanks Raf,

Actually what I am trying to do is give the user access to the database through the web page as though he were in access. That is he can move around the records (one visible at a time) and add data, edit data and delete records. The problem is that the bookmarks weren't working as expected. I am looking at using the absoluteposition property instead. Problem is I'll have to deal with changes in the recordset for delete and add.

I looked at the tutorial you pointed out and I'll have to study it a little closer. I had done searches on google for Bookmark property, recordset object, etc. Never thought about recordset "paging".

Thanks again for your help. Hopefully I can move on from here.

raf
08-10-2003, 09:16 PM
Just let us know if you nees some info on something.