Results 1 to 6 of 6

Thread: Recordset.Bookmark property in VBScript

  1. #1

    Thread Starter
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827

    Post

    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.

  2. #2
    Member
    Join Date
    Nov 1999
    Posts
    63

    Post

    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

  3. #3
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    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

  4. #4
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    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?

  5. #5

    Thread Starter
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827

    Post

    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?

  6. #6

    Thread Starter
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827

    Post

    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


Posting Permissions

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



Click Here to Expand Forum to Full Width