Why adOpenForwardOnly allows update records?

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Why adOpenForwardOnly allows update records?

    Why when I open a recordset with a adOpenForwardOnly cursor it''s
    allows me to update and add records?

    I tried to open my query with all types of cursors and all of them allows me to update records.

    adOpenForwardOnly=0
    adOpenKeyset=1
    adOpenDynamic=2
    adOpenStatic=3

    Based on all i have read, opening a recordset with adOpenForwardOnly for example,
    the cursor can''t move backward and records can''t be updated.

    What happen?, with ASP this dosen''t work?

    If anybody can help me...

    Thanks

    Susana Robledo

    -----------------------------
    This message is posted by [url]http://Asp.ForumsZone.com[/url]

    Susana Guest

  2. Similar Questions and Discussions

    1. HELP!! I need to know how to update records properly
      I'm a DW newbie and need to know how to update multiple records within a repeated region. The DW manuals only explain how to update one record at a...
    2. How to update records using list???
      I have a table with ID and ParentID columns. ID column has values like:10,13,14,15,16 ParentID has values like : 0,10,13,14,15 I also have...
    3. Update records ASP
      Hi who can help me out here? I have a field like this: <input name="link1" value="<%= rstemp("link1") %>"> And this is the new input: <a...
    4. ANN: Update Multiple Records in ASP
      I've put together an article and demo on how to batch update records in a recordset: ...
    5. Update / Add New Records
      I have tried every suggestion I could find on how to set up a form that is using a combo box for record editing to allow the user to add more...
  3. #2

    Default Re: Why adOpenForwardOnly allows update records?

    Strange. The documentation says: "The default cursor for an ADO Recordset is
    a forward-only, read-only cursor located on the server."
    That means, if you do not specify the locktype, you should get a read-only
    cursor. I tested it with this code:

    Dim cn, rs,sServer,sSQL
    sServer = "servername"
    Set cn=server.createobject("adodb.connection")
    Cn.open "Provider=SQLOLEDB;Initial Catalog=" & _
    "Northwind;Data Source=" & sServer & _
    ";UID=xxxxx;Password=xxxxx"
    Set rs=server.createobject("adodb.recordset")
    sSQL="SELECT EmployeeID, LastName,FirstName " & _
    "FROM dbo.Employees"
    rs.Open sSQL,cn,,,adCmdText
    rs(1) = "a" & rs(1)
    rs.Update
    Response.Write rs(1)
    rs.Close
    Set rs = nothing
    Cn.close
    Set cn=nothing

    Sure enough, I got this error message:
    Current Recordset does not support updating. This may be a limitation of the
    provider, or of the selected locktype.

    I then tried this:
    set rs = cn.execute ssql,,adcmdtext

    and got the same result.

    Bob Barrows

    Susana wrote:
    > Why when I open a recordset with a adOpenForwardOnly cursor it''s
    > allows me to update and add records?
    >
    > I tried to open my query with all types of cursors and all of them
    > allows me to update records.
    >
    > adOpenForwardOnly=0
    > adOpenKeyset=1
    > adOpenDynamic=2
    > adOpenStatic=3
    >
    > Based on all i have read, opening a recordset with adOpenForwardOnly
    > for example,
    > the cursor can''t move backward and records can''t be updated.
    >
    > What happen?, with ASP this dosen''t work?
    >
    > If anybody can help me...
    >
    > Thanks
    >
    > Susana Robledo
    >
    > -----------------------------
    > This message is posted by [url]http://Asp.ForumsZone.com[/url]

    Bob Barrows Guest

  4. #3

    Default Re: Why adOpenForwardOnly allows update records?



    Thanks Bob for answer.

    But you get this error because you are using a adLockReadOnly (1) lock
    type.

    Why don't you try to use another lock type such as adLockOptimistic
    (3)or adLockPessimistic (2)?

    Open the recordset with adOpenForwardOnly (0) Cursor type and you'll see
    that there's no error there. (???)

    Thanks

    Susana

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Susana Robledo Guest

  5. #4

    Default Re: Why adOpenForwardOnly allows update records?

    Where did you read that a forwardOnly cursor makes all locktypes read only?




    "Susana Robledo" <anonymous@devdex.com> wrote in message
    news:#QoHUf6SDHA.1916@TK2MSFTNGP12.phx.gbl...
    >
    >
    > Thanks Bob for answer.
    >
    > But you get this error because you are using a adLockReadOnly (1) lock
    > type.
    >
    > Why don't you try to use another lock type such as adLockOptimistic
    > (3)or adLockPessimistic (2)?
    >
    > Open the recordset with adOpenForwardOnly (0) Cursor type and you'll see
    > that there's no error there. (???)
    >
    > Thanks
    >
    > Susana
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    Aaron Bertrand - MVP Guest

  6. #5

    Default Re: Why adOpenForwardOnly allows update records?

    Susana Robledo wrote:
    > Thanks Bob for answer.
    >
    > But you get this error because you are using a adLockReadOnly (1) lock
    > type.
    >
    > Why don't you try to use another lock type such as adLockOptimistic
    > (3)or adLockPessimistic (2)?
    >
    I thought you were questioning why you get an updatable recordset when using
    adForwardOnly! If you use adLockOptimistic (3)or adLockPessimistic (2), you
    will get an updatable cursor regardless of cursor type.
    > Open the recordset with adOpenForwardOnly (0) Cursor type and you'll
    > see that there's no error there. (???)
    I DID open with adOpenForwardOnly. When you don't specify the type, you get
    the default type, which is adOpenForwardOnly.

    Please show the code that has you puzzled.

    Bob Barrows


    Bob Barrows Guest

  7. #6

    Default Re: Why adOpenForwardOnly allows update records?

    What locktype you get depends on:
    a) what cursor type you ask for
    b) the cursor location specified
    c) what the provider supports.

    For example, if you specify a client-side cursor, you will always get an
    adOpenStatic cursor. For some providers the lock type will also change.

    Jet (Access), for example, only supports a limited number of possible
    combinations. Asking for any sort of updateable cursor results in the cursor
    type changing (to Keyset or Static), even if you ask for a ForwardOnly
    cursor. What you need to do is check *after* you have opened the recordset
    to see what you actually got:

    <%
    objRS.LockType = adLockOptimistic
    objRS.CursorType = adOpenForwardOnly
    objRS.Open

    Response.Write("Lock type is now: " & objRS.LockType)
    Response.Write("Cursor type is now: " & objRS.CursorType)
    %>

    [url]http://www.adopenstatic.com/faq/jetcursortypes.asp[/url]

    Cheers
    Ken



    "Susana Robledo" <anonymous@devdex.com> wrote in message
    news:%23QoHUf6SDHA.1916@TK2MSFTNGP12.phx.gbl...
    :
    :
    : Thanks Bob for answer.
    :
    : But you get this error because you are using a adLockReadOnly (1) lock
    : type.
    :
    : Why don't you try to use another lock type such as adLockOptimistic
    : (3)or adLockPessimistic (2)?
    :
    : Open the recordset with adOpenForwardOnly (0) Cursor type and you'll see
    : that there's no error there. (???)
    :
    : Thanks
    :
    : Susana
    :
    : *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    : Don't just participate in USENET...get rewarded for it!


    Ken Schaefer Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139