Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Re: Update question


Message #1 by "Ian Richardson" <ian@i...> on Wed, 10 Jul 2002 14:26:45 +0100
Hi Ken,
Sorry for the delay in responding to this, I've been on my annual holidays.

I follow what you are saying but referring to my original comment, I just
cannot get my head around it.
Would you mind checking the below code and advising? I have a hidden field
in the form which holds is called txtUID and holds the RecordID.

many thanks Ken



If Request.querystring("update") = "yes" Then
Set UpdateItem = Server.CreateObject("ADODB.Recordset")
strBasketID = Session("BasketID")
If Request.Form("txtUID").Count > 0 then
For Each x in Request.Form("txtUID")

'sets the fields to update
strBasketID = Session("BasketID")
strItem = Request.Form("txtItem")
strPrice = Request.Form("txtPrice")
strQuantity = Request.Form("txtQuantity")
strDatePurchased = date()
strSplit = Request.Form("txtUID")

strSQL = "SELECT * FROM tblBasket  WHERE UID = " & strSplit & "  AND
BasketID = ' " & strBasketID &"' "
UpdateItem.Open strSQL, con, adOpenStatic, adLockOptimistic

'performs the update
UpdateItem.Update
UpdateItem("BasketID") = Session("BasketID")
UpdateItem("Item") = strItem
UpdateItem("Price") = (strPrice)
UpdateItem("TransactionValue") = (strPrice * strQuantity)
UpdateItem("Quantity") = strQuantity
UpdateItem("DatePurchased") = strDatePurchased
UpdateItem.update
Next
End If

Else
'shows basket contents prior to update
Set viewbasket = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM tblBasket  WHERE BasketID = '" & strBasketID & "'"
viewbasket.Open strSQL, con, adOpenStatic, adLockOptimistic
End If



----- Original Message -----
From: "Ken Schaefer" <ken@a...>
To: "Access ASP" <access_asp@p...>
Sent: Tuesday, June 18, 2002 12:01 AM
Subject: [access_asp] Re: Update question


> Create hidden inputs to store the Record IDs. These hidden input(s) should
> have the same *name*.
>
> Create the checkboxes with the name based on the record ID, and the value
> equal to however many items the user has, eg:
>
> <!-- Name is the same, value is recordID -->
> <input type="hidden" name="RecordID" value="1">
> <input type="hidden" name="RecordID" value="2">
> <input type="hidden" name="RecordID" value="3">
>
> <!-- Name based on recordID, value is quantity>
> <input type="checkbox" name="Quant_1" value="6">
> <input type="checkbox" name="Quant_2" value="18">
> <input type="checkbox" name="Quant_3" value="42">
>
> Then on the processing ASP page you can do:
>
> <%
> If Request.Form("RecordID").Count > 0 then
>
>     For Each x in Request.Form("RecordID")
>
>         Response.Write(x & " = " & Request.Form("Quant_" & x) & "<br>")
>
>     Next
>
> End If
> %>
>
> Cheers
> Ken
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ----- Original Message -----
> From: "Ian Richardson" <ian@i...>
> To: "Access ASP" <access_asp@p...>
> Sent: Monday, June 17, 2002 12:35 PM
> Subject: [access_asp] Update question
>
>
> : Hi,
> : This is a really dumb question but it has got me stumped!
> : I am building a small shopping cart and I have a dynamically generated
> : list/form of the users's selected items and I want to allow them to be
> : able change quanities in any/all item/s in their list and update all
item
> : quantities at the same time using one update button.
> :
> : My question is how can I loop through the list/form and update each
> record.
> : My code is below which does not update the database:
> :
> :
> : I apologise for this question I feel I should be able to suss this but I
> : just cannot get it.
> :
> : Cheers
> :
> : ian
>
>
>
>


  Return to Index