Update a record in database

Results 1 to 4 of 4

Thread: Update a record in database

  1. #1
    Join Date
    Dec 1969

    Default Update a record in database

    I am trying to update a record in a database using the following code:<BR>set ordersDB = Server.CreateObject("ADODB.Connection")ordersDB.Op en "invita-13.data"<BR>sqlText = "SELECT * FROM order_item WHERE (order_id = " & p_orderid <BR>sqlText = sqlText & " AND item_id = " & p_orderitemid & " )"<BR>set orderitemSet = Server.CreateObject("ADODB.Recordset")<BR>orderite mSet.Open sqlText, ordersDB<BR>l_quantity = request("p_invitationnumber")<BR>orderitemSet("qua ntity") = l_quantity<BR>orderitemSet("category") = "wedding"<BR>orderitemSet("sub_category") = "inv"<BR>orderitemSet.Update<BR><BR>And then I get the following error message:<BR>ADODB.Field error &#039 800a0cb3&#039 <BR>The operation requested by the application is not supported by the provider. <BR>/order/subsave.inc, line 15 <BR><BR>Thank you for any suggestions!<BR><BR>

  2. #2
    walt Guest

    Default RE: Update a record in database

    I have found it to be much easier in general to formulate an update query ("update order_item set category = &#039wedding&#039...") and execute that rather than trying to use the update method. Using the update method assumes you are using a provider that gives you an updatable recordset, which is not always true. It also requires you to walk through your recordset and update each record rather than firing off one query to update everything that needs it.

  3. #3
    aa Guest

    Default RE: Update a record in database


  4. #4
    Olivier Guest

    Default RE: Update a record in database

    I found the answer myself.<BR>You have to change the LockType when you open the recordset.<BR><BR>set orderitemSet = Server.CreateObject("ADODB.Recordset")<BR>orderite mSet.LockType = adLockOptimistic &#039&#060;---- added this line<BR>orderitemSet.Open sqlText, ordersDB<BR><BR>When you declare a recordset the default lock type is adLockReadOnly, which obviously does not allow updates.

Posting Permissions

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