Click to See Complete Forum and Search --> : Recordset.Bookmark property in VBScript
HarryW
Jan 9th, 2000, 07:04 PM
Hi all. I'm having real trouble getting anything to do with the bookmark property of a recordset to work. I want to put all the bookmarks of all the records in a RS into an array, so that I can use the array to go straight to a specific record in the RS. My current code looks something like:
<SELECT NAME="dcombo">
<%docreg_rs.movefirst%>
<%do while not docreg_rs.eof%>
<OPTION VALUE=<%=recnum%>> <%=docreg_rs.fields("RefNo")%>
<%docreg_rs.MoveNext
RecArray(recnum) = docreg_rs.Bookmark
recnum = recnum + 1%>
</OPTION>
<%Loop%>
<%Session("RecBooks") = RecArray
docreg_rs.Close%>
</SELECT>
If anyone can see a problem, or has ANY ideas, please reply!
Thanks.
Gerald
Jan 10th, 2000, 05:22 AM
Could you describe the problem you are having in more detail? The only potential problem I can see in your code is that the MoveNext should probably be at the bottom of your loop. As it is right now you're not getting the first bookmark of your recordset into the array.
Try using this...
<%RecArray(recnum) = docreg_rs.Bookmark
recnum = recnum + 1
docreg_rs.MoveNext%>
Gerald
Clunietp
Jan 10th, 2000, 10:09 AM
When you get a recordset using the connection.execute method, it will return a read-only, forward-only recordset. Bookmarks are not supported in forward-only recordsets. You need to open the recordset explicitly...
ex.
replace:
Set docreg_rs=conn.execute(sql)
with
docreg_rs.open SQL, conn, 1, 1
the first 1 is for adOpenKeyset and the second 1 is for adLockReadOnly. Of course, you cannot use those enum names like you can in VB because you are using VBScript
Enjoy
Tom
Clunietp
Jan 10th, 2000, 11:33 AM
does your recordset support bookmarks? I believe you have to open it as dynamic, keyset or static. Forward-only recordsets do not support bookmarks
what does your DOCREG_RS.Open method look like?
HarryW
Jan 10th, 2000, 11:59 AM
I don't think there is one, the RS is just created from an SQL statement at the start of the page:
<%
Set conn=Session.StaticObjects("docreg_conn")
sql = "SELECT * FROM docs"
Set docreg_rs=conn.execute(sql)
Dim recnum
ReDim RecArray(100)
recnum = 1
%>
I'm picking up from where someone left off here, and I'm still learning ASP, so I'm not entirely sure about what some of this means.
I've searched on the internet and found out about cursor types (?), which I think might be what you are referring to, and I've read something about forward only recordsets, but I'm not sure what either are. I have tried adding a statement to test whether bookmarks are supported:
Response.Write Docreg_rs.supports(adBookmarks)
I get the result "True". Using the same method, I have found that "CursorType" = 0.
I know the default is forward-only, and I don't think I've asked for anything else, so it may well be that. If you think this is the problem, how can I open the RS correctly?
HarryW
Jan 10th, 2000, 05:14 PM
Thanks a lot, that's exactly what I needed. You've been a great help.
I had to create the recordset object docreg_rs first, which I think is OK, but now there seems to be something wrong with my docreg_rs.Open statement. I get the message:
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.
/cgi-bin/docreg/seldoc.asp, line 6
I'm not sure what this is; I know it's something to do with the open method statement, but I'm not sure what yet. Thanks for all your help anyway, hopefully I'll be able to work this one out myself :)
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.