Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: RE: For Each loops


Message #1 by "jparlato" <jparlato@m...> on Thu, 11 Jul 2002 21:43:30 -0400
What I might suggest is that you invoke a java script that will do the
looping thru the form fields and as it does this,
create an update gram in as as string.

Then do an http post to an asp page, with server side programming,
that will use ado to post the update gram.

This assumes you are familiar with this techknology, and are useing
sql server for the data base.

You an email me
for some sample code.



-----Original Message-----
From: Ian Richardson [mailto:ian@i...]
Sent: Thursday, July 11, 2002 8:56 PM
To: ASP Databases
Subject: [asp_databases] RE: For Each loops


Hi Ron,

I apologise for the vagueness of my post. I will try to explain,

A user clicks on the button 'View Basket' and a page is displayed that takes
the selected items from the database and displays them on the page, the
quantity value is in a form element, the rest are written to the page but
with hidden fields holding the values as well. If the user wishes to change
the quantity of any item they can do so and then hit the update button, the
next script should then loop thro' the form and update the database with the
new quantities and prices.

If there were 3 items in the basket the form would look like:
<form>
' 1 item's info
<input type="hidden" name="txtUID" value="<%=viewbasket("UID")%>">
<input type="hidden" name="txtItem" value="<%=viewbasket("Item")%>">
<input type="hidden" name="txtPrice" value="<%=viewbasket("Price")%>">
<input type="hidden" name="txtPrice" value="<%=viewbasket("Price")%>">
<input type="text" name="txtQuantity" value="<%=strQuantity%>">
' 2 item's info
<input type="hidden" name="txtUID" value="<%=viewbasket("UID")%>">
<input type="hidden" name="txtItem" value="<%=viewbasket("Item")%>">
<input type="hidden" name="txtPrice" value="<%=viewbasket("Price")%>">
<input type="text" name="txtQuantity" value="<%=strQuantity%>">
' 3 item's info
<input type="hidden" name="txtUID" value="<%=viewbasket("UID")%>">
<input type="hidden" name="txtItem" value="<%=viewbasket("Item")%>">
<input type="hidden" name="txtPrice" value="<%=viewbasket("Price")%>">
<input type="text" name="txtQuantity"
value="<%=Request.QueryString("Quantity")%>">
</form>

what i need to do is loop thro' the form taking each txtUID and updating the
record that goes with txtUID.

there could be 'n' number of items in the basket.

your help is very much appreciated.

ian




----- Original Message -----
From: "Drew, Ron" <RDrew@B...>
To: "ASP Databases" <asp_databases@p...>
Sent: Thursday, July 11, 2002 9:19 PM
Subject: [asp_databases] RE: For Each loops


Yes you can next arrays.  Is the key txtUID and each key can have
muliple txtItem/txtPrice combinations.  I am trying the understand the
process flow for your shopping cart and how the visitor selected the
items to update.

-----Original Message-----
From: Ian Richardson [mailto:ian@i...]
Sent: Thursday, July 11, 2002 12:27 PM
To: ASP Databases
Subject: [asp_databases] RE: For Each loops


Hi Ron,

your example worked a treat, thank you. Unfortunately I am now getting
the same problems with other hidden fields in my basket. is it possible
to nest the Arrays, I have 3 hidden fields all together:

<input type="hidden" name="txtUID" value="<%=viewbasket("UID")%>">
<input type="hidden" name="txtItem" value="<%=viewbasket("Item")%>">
<input type="hidden" name="txtPrice" value="<%=viewbasket("Price")%>">

 and I guess I now have 3 arrays to deal with when updating?

How would i deal with this?

cheers

ian


----- Original Message -----
From: "Drew, Ron" <RDrew@B...>
To: "ASP Databases" <asp_databases@p...>
Sent: Thursday, July 11, 2002 3:58 PM
Subject: [asp_databases] RE: For Each loops


Example of split
<%
Dim MyArray
Set UpdateItem = Server.CreateObject("ADODB.Recordset")
MyArray = Split(Request.Form("txtUID"), ",")
For i = 0 to UBound(MyArray)
 strBasketID = Session("BasketID")
 strItem = Request.Form("txtItem")
 strPrice = Request.Form("txtPrice")
 strQuantity = Request.Form("txtQuantity")
 strDatePurchased = date()
 strSplit = MyArray(i)
 'check for data type
 strSQL = "SELECT * FROM tblBasket  WHERE UID =   " & strSplit & "  AND
 BasketID = '" & strBasketID  & "'  "
 response.write strSQL  & "<br>"
 UpdateItem.Open strSQL, con, adOpenStatic, adLockOptimistic
UpdateItem.Update
 UpdateItem("BasketID") = Session("BasketID")
 UpdateItem("Item") = strItem
 UpdateItem("Price") = (strPrice)
 UpdateItem("TransactionValue") = (strPrice * strQuantity)
 UpdateItem("Quantity") = strQuantity
 UpdateItem("DatePurchased") = strDatePurchased
 UpdateItem.update
 response.write strSplit  & "<br>" Next 'response.redirect "basket.asp"
%>


-----Original Message-----
From: Ian Richardson [mailto:ian@i...]
Sent: Thursday, July 11, 2002 10:03 AM
To: ASP Databases
Subject: [asp_databases] RE: For Each loops


Hi Ron,

Thanks for all your help, it's much appreciated. I am struggling with
this tho'. I have included your code into my script and now get the
following error:


Microsoft VBScript compilation error '800a03ea'

Syntax error

/trials/dev/update.asp, line 39

If cnt = 0  then
Please forgive me for being stupid but the offending code is:

For Each txtUID in Request.Form("txtUID")
strBasketID = Session("BasketID")
strItem = Request.Form("txtItem")
strPrice = Request.Form("txtPrice")
strQuantity = Request.Form("txtQuantity")
strDatePurchased = date()
strSplit = Request.Form("txtUID")
Dim cntif strSplit="" thencnt = 0
elseif
isArray(strSplit) then
cnt = 2
Else
cnt = 1
end if


strSQL = "SELECT * FROM tblBasket " & _
///this is the line causeing the error If cnt = 0  then  "WHERE BasketID
= '" & strBasketID & "';"End ifIf cnt = 1 then  "WHERE UID = " &
strSplit & " AND BasketID = '" & strBasketID & "';"End if If cnt = 2
then  "WHERE UID IN (" & strSplit & ") AND BasketID = '" & strBasketID
&"';" End if could you help? ian
----- Original Message -----
From: "Drew, Ron" <RDrew@B...>
To: "ASP Databases" <asp_databases@p...>
Sent: Thursday, July 11, 2002 2:42 PM
Subject: [asp_databases] RE: For Each loops


OK...have 2 ifs below.  Test the cnt first.
One if would take care of only one update based on cnt = 1.
One if based on cnt = 2..do a split on the strSplit based on a "," and
loop thru the array created by the split to update records.

-----Original Message-----
From: Ian Richardson [mailto:ian@i...]
Sent: Thursday, July 11, 2002 9:30 AM
To: ASP Databases
Subject: [asp_databases] RE: For Each loops


Hi Ron,
Yes each txtUID is a record. The form is a shopping cart and I am trying
to allow users to update the quantities before final submission, so the
form holds the contents of their shopping basket, the basket is
identified by the strBasketID and the item/record to update is
identified by txtUID. Where I have put <input type="hidden"
name="txtUID" value="1"> the actual code for this would be <input
type="hidden" name="txtUID" value="<%=viewbasket("UID")%>">

hth

ian



----- Original Message -----
From: "Drew, Ron" <RDrew@B...>
To: "ASP Databases" <asp_databases@p...>
Sent: Thursday, July 11, 2002 1:07 PM
Subject: [asp_databases] RE: For Each loops


I THINK THIS WILL WORK FOR YOU..BUT NOT SEEING THE FORM ITSELF..THIS MAY
CHANGE..IS EACH txtUID A RECORD IN ITSELF?

strSplit = Request.Form("txtUID")
'-----------------------------
Dim cnt
if strSplit="" then
cnt = 0
elseif isArray(strSplit) then
cnt = 2
else
cnt = 1
end if
'----------------------------
strSQL = "SELECT * FROM tblBasket " &_
If cnt = 0 then
  "WHERE BasketID = '" & strBasketID & "';"
End if
If cnt = 1 then
  "WHERE UID = " & strSplit & " AND BasketID = '" & strBasketID & "';"
End if If cnt = 2 then
  "WHERE UID IN (" & strSplit & ") AND BasketID = '" & strBasketID &
"';" End if

-----Original Message-----
From: Ian Richardson [mailto:ian@i...]
Sent: Thursday, July 11, 2002 6:45 AM
To: ASP Databases
Subject: [asp_databases] For Each loops


Hello

I apologise in advance for this question but I have one of those blocks
that I cannot get my head around. I want to be able to update a database

with new values taken from a form. The form element will have the same
name but different values. For example: <form> <input type="hidden"
name="txtUID" value="1"> <input type="hidden" name="txtUID" value="2">
<input type="hidden" name="txtUID" value="3"> </form>

I wish to be able to loop thro' this collection and take each new value
for txtUID and update the appropriate record, my code is below but I get

the following erro msg:

Microsoft JET Database Engine error '80040e14'
Syntax error (comma) in query expression 'UID = 21, 22 AND BasketID 
'796606393''. /trials/dev/update.asp, line 30

can anybady help me to solve this problem?

many thanks

ian

<%
Set UpdateItem = Server.CreateObject("ADODB.Recordset")
strBasketID = Session("BasketID")

For Each txtUID in Request.Form("txtUID")
strBasketID = Session("BasketID")
strItem = Request.Form("txtItem")
strPrice = Request.Form("txtPrice")
strQuantity = Request.Form("txtQuantity")
strDatePurchased = date()
strSplit = Request.Form("txtUID")
'check for data type
strSQL = "SELECT * FROM tblBasket  WHERE UID =   " & strSplit & "  AND
BasketID = '" & strBasketID  & "'  "
response.write strSQL  & "<br>"
UpdateItem.Open strSQL, con, adOpenStatic, adLockOptimistic
UpdateItem.Update
UpdateItem("BasketID") = Session("BasketID")
UpdateItem("Item") = strItem
UpdateItem("Price") = (strPrice)
UpdateItem("TransactionValue") = (strPrice * strQuantity)
UpdateItem("Quantity") = strQuantity
UpdateItem("DatePurchased") = strDatePurchased UpdateItem.update
response.write strSplit  & "<br>" Next 'response.redirect "basket.asp"
%>
---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 

---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 



---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 

---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 



---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 

---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 






Message #2 by "Drew, Ron" <RDrew@B...> on Thu, 11 Jul 2002 16:19:25 -0400
Yes you can next arrays.  Is the key txtUID and each key can have
muliple txtItem/txtPrice combinations.  I am trying the understand the
process flow for your shopping cart and how the visitor selected the
items to update.

-----Original Message-----
From: Ian Richardson [mailto:ian@i...]
Sent: Thursday, July 11, 2002 12:27 PM
To: ASP Databases
Subject: [asp_databases] RE: For Each loops


Hi Ron,

your example worked a treat, thank you. Unfortunately I am now getting
the same problems with other hidden fields in my basket. is it possible
to nest the Arrays, I have 3 hidden fields all together:

<input type=3D"hidden" name=3D"txtUID" 
value=3D"<%=3Dviewbasket("UID")%>">
<input type=3D"hidden" name=3D"txtItem" 
value=3D"<%=3Dviewbasket("Item")%>">
<input type=3D"hidden" name=3D"txtPrice" 
value=3D"<%=3Dviewbasket("Price")%>">

 and I guess I now have 3 arrays to deal with when updating?

How would i deal with this?

cheers

ian


----- Original Message -----
From: "Drew, Ron" <RDrew@B...>
To: "ASP Databases" <asp_databases@p...>
Sent: Thursday, July 11, 2002 3:58 PM
Subject: [asp_databases] RE: For Each loops


Example of split
<%
Dim MyArray
Set UpdateItem =3D Server.CreateObject("ADODB.Recordset")
MyArray =3D Split(Request.Form("txtUID"), ",")
For i =3D 0 to UBound(MyArray)
 strBasketID =3D Session("BasketID")
 strItem =3D Request.Form("txtItem")
 strPrice =3D Request.Form("txtPrice")
 strQuantity =3D Request.Form("txtQuantity")
 strDatePurchased =3D date()
 strSplit =3D MyArray(i)
 'check for data type
 strSQL =3D "SELECT * FROM tblBasket  WHERE UID =3D   " & strSplit & "  
AND
 BasketID =3D '" & strBasketID  & "'  "
 response.write strSQL  & "<br>"
 UpdateItem.Open strSQL, con, adOpenStatic, adLockOptimistic
UpdateItem.Update
 UpdateItem("BasketID") =3D Session("BasketID")
 UpdateItem("Item") =3D strItem
 UpdateItem("Price") =3D (strPrice)
 UpdateItem("TransactionValue") =3D (strPrice * strQuantity)
 UpdateItem("Quantity") =3D strQuantity
 UpdateItem("DatePurchased") =3D strDatePurchased
 UpdateItem.update
 response.write strSplit  & "<br>" Next 'response.redirect "basket.asp"
%>


-----Original Message-----
From: Ian Richardson [mailto:ian@i...]
Sent: Thursday, July 11, 2002 10:03 AM
To: ASP Databases
Subject: [asp_databases] RE: For Each loops


Hi Ron,

Thanks for all your help, it's much appreciated. I am struggling with
this tho'. I have included your code into my script and now get the
following error:


Microsoft VBScript compilation error '800a03ea'

Syntax error

/trials/dev/update.asp, line 39

If cnt =3D 0  then
Please forgive me for being stupid but the offending code is:

For Each txtUID in Request.Form("txtUID")
strBasketID =3D Session("BasketID")
strItem =3D Request.Form("txtItem")
strPrice =3D Request.Form("txtPrice")
strQuantity =3D Request.Form("txtQuantity")
strDatePurchased =3D date()
strSplit =3D Request.Form("txtUID")
Dim cntif strSplit=3D"" thencnt =3D 0
elseif
isArray(strSplit) then
cnt =3D 2
Else
cnt =3D 1
end if


strSQL =3D "SELECT * FROM tblBasket " & _
///this is the line causeing the error If cnt =3D 0  then  "WHERE 
BasketID
=3D '" & strBasketID & "';"End ifIf cnt =3D 1 then  "WHERE UID =3D " &
strSplit & " AND BasketID =3D '" & strBasketID & "';"End if If cnt =3D 2
then  "WHERE UID IN (" & strSplit & ") AND BasketID =3D '" & strBasketID
&"';" End if could you help? ian
----- Original Message -----
From: "Drew, Ron" <RDrew@B...>
To: "ASP Databases" <asp_databases@p...>
Sent: Thursday, July 11, 2002 2:42 PM
Subject: [asp_databases] RE: For Each loops


OK...have 2 ifs below.  Test the cnt first.
One if would take care of only one update based on cnt =3D 1.
One if based on cnt =3D 2..do a split on the strSplit based on a "," and
loop thru the array created by the split to update records.

-----Original Message-----
From: Ian Richardson [mailto:ian@i...]
Sent: Thursday, July 11, 2002 9:30 AM
To: ASP Databases
Subject: [asp_databases] RE: For Each loops


Hi Ron,
Yes each txtUID is a record. The form is a shopping cart and I am trying
to allow users to update the quantities before final submission, so the
form holds the contents of their shopping basket, the basket is
identified by the strBasketID and the item/record to update is
identified by txtUID. Where I have put <input type=3D"hidden"
name=3D"txtUID" value=3D"1"> the actual code for this would be <input
type=3D"hidden" name=3D"txtUID" value=3D"<%=3Dviewbasket("UID")%>">

hth

ian



----- Original Message -----
From: "Drew, Ron" <RDrew@B...>
To: "ASP Databases" <asp_databases@p...>
Sent: Thursday, July 11, 2002 1:07 PM
Subject: [asp_databases] RE: For Each loops


I THINK THIS WILL WORK FOR YOU..BUT NOT SEEING THE FORM ITSELF..THIS MAY
CHANGE..IS EACH txtUID A RECORD IN ITSELF?

strSplit =3D Request.Form("txtUID")
'-----------------------------
Dim cnt
if strSplit=3D"" then
cnt =3D 0
elseif isArray(strSplit) then
cnt =3D 2
else
cnt =3D 1
end if
'----------------------------
strSQL =3D "SELECT * FROM tblBasket " &_
If cnt =3D 0 then
  "WHERE BasketID =3D '" & strBasketID & "';"
End if
If cnt =3D 1 then
  "WHERE UID =3D " & strSplit & " AND BasketID =3D '" & strBasketID & 
"';"
End if If cnt =3D 2 then
  "WHERE UID IN (" & strSplit & ") AND BasketID =3D '" & strBasketID &
"';" End if

-----Original Message-----
From: Ian Richardson [mailto:ian@i...]
Sent: Thursday, July 11, 2002 6:45 AM
To: ASP Databases
Subject: [asp_databases] For Each loops


Hello

I apologise in advance for this question but I have one of those blocks
that I cannot get my head around. I want to be able to update a database

with new values taken from a form. The form element will have the same
name but different values. For example: <form> <input type=3D"hidden"
name=3D"txtUID" value=3D"1"> <input type=3D"hidden" name=3D"txtUID" 
value=3D"2">
<input type=3D"hidden" name=3D"txtUID" value=3D"3"> </form>

I wish to be able to loop thro' this collection and take each new value
for txtUID and update the appropriate record, my code is below but I get

the following erro msg:

Microsoft JET Database Engine error '80040e14'
Syntax error (comma) in query expression 'UID =3D 21, 22 AND BasketID 
=3D
'796606393''. /trials/dev/update.asp, line 30

can anybady help me to solve this problem?

many thanks

ian

<%
Set UpdateItem =3D Server.CreateObject("ADODB.Recordset")
strBasketID =3D Session("BasketID")

For Each txtUID in Request.Form("txtUID")
strBasketID =3D Session("BasketID")
strItem =3D Request.Form("txtItem")
strPrice =3D Request.Form("txtPrice")
strQuantity =3D Request.Form("txtQuantity")
strDatePurchased =3D date()
strSplit =3D Request.Form("txtUID")
'check for data type
strSQL =3D "SELECT * FROM tblBasket  WHERE UID =3D   " & strSplit & "  
AND
BasketID =3D '" & strBasketID  & "'  "
response.write strSQL  & "<br>"
UpdateItem.Open strSQL, con, adOpenStatic, adLockOptimistic
UpdateItem.Update
UpdateItem("BasketID") =3D Session("BasketID")
UpdateItem("Item") =3D strItem
UpdateItem("Price") =3D (strPrice)
UpdateItem("TransactionValue") =3D (strPrice * strQuantity)
UpdateItem("Quantity") =3D strQuantity
UpdateItem("DatePurchased") =3D strDatePurchased UpdateItem.update
response.write strSplit  & "<br>" Next 'response.redirect "basket.asp"
%>
---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 

---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 



---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 

---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 



---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 

---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 


Message #3 by "Ian Richardson" <ian@i...> on Fri, 12 Jul 2002 01:56:25 +0100
Hi Ron,

I apologise for the vagueness of my post. I will try to explain,

A user clicks on the button 'View Basket' and a page is displayed that takes
the selected items from the database and displays them on the page, the
quantity value is in a form element, the rest are written to the page but
with hidden fields holding the values as well. If the user wishes to change
the quantity of any item they can do so and then hit the update button, the
next script should then loop thro' the form and update the database with the
new quantities and prices.

If there were 3 items in the basket the form would look like:
<form>
' 1 item's info
<input type="hidden" name="txtUID" value="<%=viewbasket("UID")%>">
<input type="hidden" name="txtItem" value="<%=viewbasket("Item")%>">
<input type="hidden" name="txtPrice" value="<%=viewbasket("Price")%>">
<input type="hidden" name="txtPrice" value="<%=viewbasket("Price")%>">
<input type="text" name="txtQuantity" value="<%=strQuantity%>">
' 2 item's info
<input type="hidden" name="txtUID" value="<%=viewbasket("UID")%>">
<input type="hidden" name="txtItem" value="<%=viewbasket("Item")%>">
<input type="hidden" name="txtPrice" value="<%=viewbasket("Price")%>">
<input type="text" name="txtQuantity" value="<%=strQuantity%>">
' 3 item's info
<input type="hidden" name="txtUID" value="<%=viewbasket("UID")%>">
<input type="hidden" name="txtItem" value="<%=viewbasket("Item")%>">
<input type="hidden" name="txtPrice" value="<%=viewbasket("Price")%>">
<input type="text" name="txtQuantity"
value="<%=Request.QueryString("Quantity")%>">
</form>

what i need to do is loop thro' the form taking each txtUID and updating the
record that goes with txtUID.

there could be 'n' number of items in the basket.

your help is very much appreciated.

ian




----- Original Message -----
From: "Drew, Ron" <RDrew@B...>
To: "ASP Databases" <asp_databases@p...>
Sent: Thursday, July 11, 2002 9:19 PM
Subject: [asp_databases] RE: For Each loops


Yes you can next arrays.  Is the key txtUID and each key can have
muliple txtItem/txtPrice combinations.  I am trying the understand the
process flow for your shopping cart and how the visitor selected the
items to update.

-----Original Message-----
From: Ian Richardson [mailto:ian@i...]
Sent: Thursday, July 11, 2002 12:27 PM
To: ASP Databases
Subject: [asp_databases] RE: For Each loops


Hi Ron,

your example worked a treat, thank you. Unfortunately I am now getting
the same problems with other hidden fields in my basket. is it possible
to nest the Arrays, I have 3 hidden fields all together:

<input type="hidden" name="txtUID" value="<%=viewbasket("UID")%>">
<input type="hidden" name="txtItem" value="<%=viewbasket("Item")%>">
<input type="hidden" name="txtPrice" value="<%=viewbasket("Price")%>">

 and I guess I now have 3 arrays to deal with when updating?

How would i deal with this?

cheers

ian


----- Original Message -----
From: "Drew, Ron" <RDrew@B...>
To: "ASP Databases" <asp_databases@p...>
Sent: Thursday, July 11, 2002 3:58 PM
Subject: [asp_databases] RE: For Each loops


Example of split
<%
Dim MyArray
Set UpdateItem = Server.CreateObject("ADODB.Recordset")
MyArray = Split(Request.Form("txtUID"), ",")
For i = 0 to UBound(MyArray)
 strBasketID = Session("BasketID")
 strItem = Request.Form("txtItem")
 strPrice = Request.Form("txtPrice")
 strQuantity = Request.Form("txtQuantity")
 strDatePurchased = date()
 strSplit = MyArray(i)
 'check for data type
 strSQL = "SELECT * FROM tblBasket  WHERE UID =   " & strSplit & "  AND
 BasketID = '" & strBasketID  & "'  "
 response.write strSQL  & "<br>"
 UpdateItem.Open strSQL, con, adOpenStatic, adLockOptimistic
UpdateItem.Update
 UpdateItem("BasketID") = Session("BasketID")
 UpdateItem("Item") = strItem
 UpdateItem("Price") = (strPrice)
 UpdateItem("TransactionValue") = (strPrice * strQuantity)
 UpdateItem("Quantity") = strQuantity
 UpdateItem("DatePurchased") = strDatePurchased
 UpdateItem.update
 response.write strSplit  & "<br>" Next 'response.redirect "basket.asp"
%>


-----Original Message-----
From: Ian Richardson [mailto:ian@i...]
Sent: Thursday, July 11, 2002 10:03 AM
To: ASP Databases
Subject: [asp_databases] RE: For Each loops


Hi Ron,

Thanks for all your help, it's much appreciated. I am struggling with
this tho'. I have included your code into my script and now get the
following error:


Microsoft VBScript compilation error '800a03ea'

Syntax error

/trials/dev/update.asp, line 39

If cnt = 0  then
Please forgive me for being stupid but the offending code is:

For Each txtUID in Request.Form("txtUID")
strBasketID = Session("BasketID")
strItem = Request.Form("txtItem")
strPrice = Request.Form("txtPrice")
strQuantity = Request.Form("txtQuantity")
strDatePurchased = date()
strSplit = Request.Form("txtUID")
Dim cntif strSplit="" thencnt = 0
elseif
isArray(strSplit) then
cnt = 2
Else
cnt = 1
end if


strSQL = "SELECT * FROM tblBasket " & _
///this is the line causeing the error If cnt = 0  then  "WHERE BasketID
= '" & strBasketID & "';"End ifIf cnt = 1 then  "WHERE UID = " &
strSplit & " AND BasketID = '" & strBasketID & "';"End if If cnt = 2
then  "WHERE UID IN (" & strSplit & ") AND BasketID = '" & strBasketID
&"';" End if could you help? ian
----- Original Message -----
From: "Drew, Ron" <RDrew@B...>
To: "ASP Databases" <asp_databases@p...>
Sent: Thursday, July 11, 2002 2:42 PM
Subject: [asp_databases] RE: For Each loops


OK...have 2 ifs below.  Test the cnt first.
One if would take care of only one update based on cnt = 1.
One if based on cnt = 2..do a split on the strSplit based on a "," and
loop thru the array created by the split to update records.

-----Original Message-----
From: Ian Richardson [mailto:ian@i...]
Sent: Thursday, July 11, 2002 9:30 AM
To: ASP Databases
Subject: [asp_databases] RE: For Each loops


Hi Ron,
Yes each txtUID is a record. The form is a shopping cart and I am trying
to allow users to update the quantities before final submission, so the
form holds the contents of their shopping basket, the basket is
identified by the strBasketID and the item/record to update is
identified by txtUID. Where I have put <input type="hidden"
name="txtUID" value="1"> the actual code for this would be <input
type="hidden" name="txtUID" value="<%=viewbasket("UID")%>">

hth

ian



----- Original Message -----
From: "Drew, Ron" <RDrew@B...>
To: "ASP Databases" <asp_databases@p...>
Sent: Thursday, July 11, 2002 1:07 PM
Subject: [asp_databases] RE: For Each loops


I THINK THIS WILL WORK FOR YOU..BUT NOT SEEING THE FORM ITSELF..THIS MAY
CHANGE..IS EACH txtUID A RECORD IN ITSELF?

strSplit = Request.Form("txtUID")
'-----------------------------
Dim cnt
if strSplit="" then
cnt = 0
elseif isArray(strSplit) then
cnt = 2
else
cnt = 1
end if
'----------------------------
strSQL = "SELECT * FROM tblBasket " &_
If cnt = 0 then
  "WHERE BasketID = '" & strBasketID & "';"
End if
If cnt = 1 then
  "WHERE UID = " & strSplit & " AND BasketID = '" & strBasketID & "';"
End if If cnt = 2 then
  "WHERE UID IN (" & strSplit & ") AND BasketID = '" & strBasketID &
"';" End if

-----Original Message-----
From: Ian Richardson [mailto:ian@i...]
Sent: Thursday, July 11, 2002 6:45 AM
To: ASP Databases
Subject: [asp_databases] For Each loops


Hello

I apologise in advance for this question but I have one of those blocks
that I cannot get my head around. I want to be able to update a database

with new values taken from a form. The form element will have the same
name but different values. For example: <form> <input type="hidden"
name="txtUID" value="1"> <input type="hidden" name="txtUID" value="2">
<input type="hidden" name="txtUID" value="3"> </form>

I wish to be able to loop thro' this collection and take each new value
for txtUID and update the appropriate record, my code is below but I get

the following erro msg:

Microsoft JET Database Engine error '80040e14'
Syntax error (comma) in query expression 'UID = 21, 22 AND BasketID 
'796606393''. /trials/dev/update.asp, line 30

can anybady help me to solve this problem?

many thanks

ian

<%
Set UpdateItem = Server.CreateObject("ADODB.Recordset")
strBasketID = Session("BasketID")

For Each txtUID in Request.Form("txtUID")
strBasketID = Session("BasketID")
strItem = Request.Form("txtItem")
strPrice = Request.Form("txtPrice")
strQuantity = Request.Form("txtQuantity")
strDatePurchased = date()
strSplit = Request.Form("txtUID")
'check for data type
strSQL = "SELECT * FROM tblBasket  WHERE UID =   " & strSplit & "  AND
BasketID = '" & strBasketID  & "'  "
response.write strSQL  & "<br>"
UpdateItem.Open strSQL, con, adOpenStatic, adLockOptimistic
UpdateItem.Update
UpdateItem("BasketID") = Session("BasketID")
UpdateItem("Item") = strItem
UpdateItem("Price") = (strPrice)
UpdateItem("TransactionValue") = (strPrice * strQuantity)
UpdateItem("Quantity") = strQuantity
UpdateItem("DatePurchased") = strDatePurchased UpdateItem.update
response.write strSplit  & "<br>" Next 'response.redirect "basket.asp"
%>
---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 

---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 



---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 

---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 



---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 

---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 




Message #4 by "Ian Richardson" <ian@i...> on Thu, 11 Jul 2002 17:27:29 +0100
Hi Ron,

your example worked a treat, thank you. Unfortunately I am now getting the
same problems with other hidden fields in my basket.
is it possible to nest the Arrays, I have 3 hidden fields all together:

<input type="hidden" name="txtUID" value="<%=viewbasket("UID")%>">
<input type="hidden" name="txtItem" value="<%=viewbasket("Item")%>">
<input type="hidden" name="txtPrice" value="<%=viewbasket("Price")%>">

 and I guess I now have 3 arrays to deal with when updating?

How would i deal with this?

cheers

ian


----- Original Message -----
From: "Drew, Ron" <RDrew@B...>
To: "ASP Databases" <asp_databases@p...>
Sent: Thursday, July 11, 2002 3:58 PM
Subject: [asp_databases] RE: For Each loops


Example of split
<%
Dim MyArray
Set UpdateItem = Server.CreateObject("ADODB.Recordset")
MyArray = Split(Request.Form("txtUID"), ",")
For i = 0 to UBound(MyArray)
 strBasketID = Session("BasketID")
 strItem = Request.Form("txtItem")
 strPrice = Request.Form("txtPrice")
 strQuantity = Request.Form("txtQuantity")
 strDatePurchased = date()
 strSplit = MyArray(i)
 'check for data type
 strSQL = "SELECT * FROM tblBasket  WHERE UID =   " & strSplit & "  AND
 BasketID = '" & strBasketID  & "'  "
 response.write strSQL  & "<br>"
 UpdateItem.Open strSQL, con, adOpenStatic, adLockOptimistic
UpdateItem.Update
 UpdateItem("BasketID") = Session("BasketID")
 UpdateItem("Item") = strItem
 UpdateItem("Price") = (strPrice)
 UpdateItem("TransactionValue") = (strPrice * strQuantity)
 UpdateItem("Quantity") = strQuantity
 UpdateItem("DatePurchased") = strDatePurchased UpdateItem.update
response.write strSplit  & "<br>"
Next
'response.redirect "basket.asp" %>


-----Original Message-----
From: Ian Richardson [mailto:ian@i...]
Sent: Thursday, July 11, 2002 10:03 AM
To: ASP Databases
Subject: [asp_databases] RE: For Each loops


Hi Ron,

Thanks for all your help, it's much appreciated. I am struggling with
this tho'. I have included your code into my script and now get the
following error:


Microsoft VBScript compilation error '800a03ea'

Syntax error

/trials/dev/update.asp, line 39

If cnt = 0  then
Please forgive me for being stupid but the offending code is:

For Each txtUID in Request.Form("txtUID")
strBasketID = Session("BasketID")
strItem = Request.Form("txtItem")
strPrice = Request.Form("txtPrice")
strQuantity = Request.Form("txtQuantity")
strDatePurchased = date()
strSplit = Request.Form("txtUID")
Dim cntif strSplit="" thencnt = 0
elseif
isArray(strSplit) then
cnt = 2
Else
cnt = 1
end if


strSQL = "SELECT * FROM tblBasket " & _
///this is the line causeing the error If cnt = 0  then  "WHERE BasketID
= '" & strBasketID & "';"End ifIf cnt = 1 then  "WHERE UID = " &
strSplit & " AND BasketID = '" & strBasketID & "';"End if If cnt = 2
then  "WHERE UID IN (" & strSplit & ") AND BasketID = '" & strBasketID
&"';" End if could you help? ian
----- Original Message -----
From: "Drew, Ron" <RDrew@B...>
To: "ASP Databases" <asp_databases@p...>
Sent: Thursday, July 11, 2002 2:42 PM
Subject: [asp_databases] RE: For Each loops


OK...have 2 ifs below.  Test the cnt first.
One if would take care of only one update based on cnt = 1.
One if based on cnt = 2..do a split on the strSplit based on a "," and
loop thru the array created by the split to update records.

-----Original Message-----
From: Ian Richardson [mailto:ian@i...]
Sent: Thursday, July 11, 2002 9:30 AM
To: ASP Databases
Subject: [asp_databases] RE: For Each loops


Hi Ron,
Yes each txtUID is a record. The form is a shopping cart and I am trying
to allow users to update the quantities before final submission, so the
form holds the contents of their shopping basket, the basket is
identified by the strBasketID and the item/record to update is
identified by txtUID. Where I have put <input type="hidden"
name="txtUID" value="1"> the actual code for this would be <input
type="hidden" name="txtUID" value="<%=viewbasket("UID")%>">

hth

ian



----- Original Message -----
From: "Drew, Ron" <RDrew@B...>
To: "ASP Databases" <asp_databases@p...>
Sent: Thursday, July 11, 2002 1:07 PM
Subject: [asp_databases] RE: For Each loops


I THINK THIS WILL WORK FOR YOU..BUT NOT SEEING THE FORM ITSELF..THIS MAY
CHANGE..IS EACH txtUID A RECORD IN ITSELF?

strSplit = Request.Form("txtUID")
'-----------------------------
Dim cnt
if strSplit="" then
cnt = 0
elseif isArray(strSplit) then
cnt = 2
else
cnt = 1
end if
'----------------------------
strSQL = "SELECT * FROM tblBasket " &_
If cnt = 0 then
  "WHERE BasketID = '" & strBasketID & "';"
End if
If cnt = 1 then
  "WHERE UID = " & strSplit & " AND BasketID = '" & strBasketID & "';"
End if If cnt = 2 then
  "WHERE UID IN (" & strSplit & ") AND BasketID = '" & strBasketID &
"';" End if

-----Original Message-----
From: Ian Richardson [mailto:ian@i...]
Sent: Thursday, July 11, 2002 6:45 AM
To: ASP Databases
Subject: [asp_databases] For Each loops


Hello

I apologise in advance for this question but I have one of those blocks
that I cannot get my head around. I want to be able to update a database

with new values taken from a form. The form element will have the same
name but different values. For example: <form> <input type="hidden"
name="txtUID" value="1"> <input type="hidden" name="txtUID" value="2">
<input type="hidden" name="txtUID" value="3"> </form>

I wish to be able to loop thro' this collection and take each new value
for txtUID and update the appropriate record, my code is below but I get

the following erro msg:

Microsoft JET Database Engine error '80040e14'
Syntax error (comma) in query expression 'UID = 21, 22 AND BasketID 
'796606393''. /trials/dev/update.asp, line 30

can anybady help me to solve this problem?

many thanks

ian

<%
Set UpdateItem = Server.CreateObject("ADODB.Recordset")
strBasketID = Session("BasketID")

For Each txtUID in Request.Form("txtUID")
strBasketID = Session("BasketID")
strItem = Request.Form("txtItem")
strPrice = Request.Form("txtPrice")
strQuantity = Request.Form("txtQuantity")
strDatePurchased = date()
strSplit = Request.Form("txtUID")
'check for data type
strSQL = "SELECT * FROM tblBasket  WHERE UID =   " & strSplit & "  AND
BasketID = '" & strBasketID  & "'  "
response.write strSQL  & "<br>"
UpdateItem.Open strSQL, con, adOpenStatic, adLockOptimistic
UpdateItem.Update
UpdateItem("BasketID") = Session("BasketID")
UpdateItem("Item") = strItem
UpdateItem("Price") = (strPrice)
UpdateItem("TransactionValue") = (strPrice * strQuantity)
UpdateItem("Quantity") = strQuantity
UpdateItem("DatePurchased") = strDatePurchased UpdateItem.update
response.write strSplit  & "<br>" Next 'response.redirect "basket.asp"
%>
---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 

---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 



---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 

---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 





Message #5 by "Drew, Ron" <RDrew@B...> on Thu, 11 Jul 2002 10:58:15 -0400
Example of split
<%
Dim MyArray
Set UpdateItem =3D Server.CreateObject("ADODB.Recordset")
MyArray =3D Split(Request.Form("txtUID"), ",")
For i =3D 0 to UBound(MyArray)
 strBasketID =3D Session("BasketID")
 strItem =3D Request.Form("txtItem")
 strPrice =3D Request.Form("txtPrice")
 strQuantity =3D Request.Form("txtQuantity")
 strDatePurchased =3D date()
 strSplit =3D MyArray(i)
 'check for data type
 strSQL =3D "SELECT * FROM tblBasket  WHERE UID =3D   " & strSplit & "  
AND
 BasketID =3D '" & strBasketID  & "'  "
 response.write strSQL  & "<br>"
 UpdateItem.Open strSQL, con, adOpenStatic, adLockOptimistic
UpdateItem.Update
 UpdateItem("BasketID") =3D Session("BasketID")
 UpdateItem("Item") =3D strItem
 UpdateItem("Price") =3D (strPrice)
 UpdateItem("TransactionValue") =3D (strPrice * strQuantity)
 UpdateItem("Quantity") =3D strQuantity
 UpdateItem("DatePurchased") =3D strDatePurchased UpdateItem.update
response.write strSplit  & "<br>"
Next   
'response.redirect "basket.asp" %>


-----Original Message-----
From: Ian Richardson [mailto:ian@i...]
Sent: Thursday, July 11, 2002 10:03 AM
To: ASP Databases
Subject: [asp_databases] RE: For Each loops


Hi Ron,

Thanks for all your help, it's much appreciated. I am struggling with
this tho'. I have included your code into my script and now get the
following error:


Microsoft VBScript compilation error '800a03ea'

Syntax error

/trials/dev/update.asp, line 39

If cnt =3D 0  then
Please forgive me for being stupid but the offending code is:

For Each txtUID in Request.Form("txtUID")
strBasketID =3D Session("BasketID")
strItem =3D Request.Form("txtItem")
strPrice =3D Request.Form("txtPrice")
strQuantity =3D Request.Form("txtQuantity")
strDatePurchased =3D date()
strSplit =3D Request.Form("txtUID")
Dim cntif strSplit=3D"" thencnt =3D 0
elseif
isArray(strSplit) then
cnt =3D 2
Else
cnt =3D 1
end if


strSQL =3D "SELECT * FROM tblBasket " & _
///this is the line causeing the error If cnt =3D 0  then  "WHERE 
BasketID
=3D '" & strBasketID & "';"End ifIf cnt =3D 1 then  "WHERE UID =3D " &
strSplit & " AND BasketID =3D '" & strBasketID & "';"End if If cnt =3D 2
then  "WHERE UID IN (" & strSplit & ") AND BasketID =3D '" & strBasketID
&"';" End if could you help? ian
----- Original Message -----
From: "Drew, Ron" <RDrew@B...>
To: "ASP Databases" <asp_databases@p...>
Sent: Thursday, July 11, 2002 2:42 PM
Subject: [asp_databases] RE: For Each loops


OK...have 2 ifs below.  Test the cnt first.
One if would take care of only one update based on cnt =3D 1.
One if based on cnt =3D 2..do a split on the strSplit based on a "," and
loop thru the array created by the split to update records.

-----Original Message-----
From: Ian Richardson [mailto:ian@i...]
Sent: Thursday, July 11, 2002 9:30 AM
To: ASP Databases
Subject: [asp_databases] RE: For Each loops


Hi Ron,
Yes each txtUID is a record. The form is a shopping cart and I am trying
to allow users to update the quantities before final submission, so the
form holds the contents of their shopping basket, the basket is
identified by the strBasketID and the item/record to update is
identified by txtUID. Where I have put <input type=3D"hidden"
name=3D"txtUID" value=3D"1"> the actual code for this would be <input
type=3D"hidden" name=3D"txtUID" value=3D"<%=3Dviewbasket("UID")%>">

hth

ian



----- Original Message -----
From: "Drew, Ron" <RDrew@B...>
To: "ASP Databases" <asp_databases@p...>
Sent: Thursday, July 11, 2002 1:07 PM
Subject: [asp_databases] RE: For Each loops


I THINK THIS WILL WORK FOR YOU..BUT NOT SEEING THE FORM ITSELF..THIS MAY
CHANGE..IS EACH txtUID A RECORD IN ITSELF?

strSplit =3D Request.Form("txtUID")
'-----------------------------
Dim cnt
if strSplit=3D"" then
cnt =3D 0
elseif isArray(strSplit) then
cnt =3D 2
else
cnt =3D 1
end if
'----------------------------
strSQL =3D "SELECT * FROM tblBasket " &_
If cnt =3D 0 then
  "WHERE BasketID =3D '" & strBasketID & "';"
End if
If cnt =3D 1 then
  "WHERE UID =3D " & strSplit & " AND BasketID =3D '" & strBasketID & 
"';"
End if If cnt =3D 2 then
  "WHERE UID IN (" & strSplit & ") AND BasketID =3D '" & strBasketID &
"';" End if

-----Original Message-----
From: Ian Richardson [mailto:ian@i...]
Sent: Thursday, July 11, 2002 6:45 AM
To: ASP Databases
Subject: [asp_databases] For Each loops


Hello

I apologise in advance for this question but I have one of those blocks
that I cannot get my head around. I want to be able to update a database

with new values taken from a form. The form element will have the same
name but different values. For example: <form> <input type=3D"hidden"
name=3D"txtUID" value=3D"1"> <input type=3D"hidden" name=3D"txtUID" 
value=3D"2">
<input type=3D"hidden" name=3D"txtUID" value=3D"3"> </form>

I wish to be able to loop thro' this collection and take each new value
for txtUID and update the appropriate record, my code is below but I get

the following erro msg:

Microsoft JET Database Engine error '80040e14'
Syntax error (comma) in query expression 'UID =3D 21, 22 AND BasketID 
=3D
'796606393''. /trials/dev/update.asp, line 30

can anybady help me to solve this problem?

many thanks

ian

<%
Set UpdateItem =3D Server.CreateObject("ADODB.Recordset")
strBasketID =3D Session("BasketID")

For Each txtUID in Request.Form("txtUID")
strBasketID =3D Session("BasketID")
strItem =3D Request.Form("txtItem")
strPrice =3D Request.Form("txtPrice")
strQuantity =3D Request.Form("txtQuantity")
strDatePurchased =3D date()
strSplit =3D Request.Form("txtUID")
'check for data type
strSQL =3D "SELECT * FROM tblBasket  WHERE UID =3D   " & strSplit & "  
AND
BasketID =3D '" & strBasketID  & "'  "
response.write strSQL  & "<br>"
UpdateItem.Open strSQL, con, adOpenStatic, adLockOptimistic
UpdateItem.Update
UpdateItem("BasketID") =3D Session("BasketID")
UpdateItem("Item") =3D strItem
UpdateItem("Price") =3D (strPrice)
UpdateItem("TransactionValue") =3D (strPrice * strQuantity)
UpdateItem("Quantity") =3D strQuantity
UpdateItem("DatePurchased") =3D strDatePurchased UpdateItem.update
response.write strSplit  & "<br>" Next 'response.redirect "basket.asp"
%>
---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 

---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 



---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 

---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 



Message #6 by "Ian Richardson" <ian@i...> on Thu, 11 Jul 2002 15:03:09 +0100
Hi Ron,

Thanks for all your help, it's much appreciated. I am struggling with this
tho'.
I have included your code into my script and now get the following error:


Microsoft VBScript compilation error '800a03ea'

Syntax error

/trials/dev/update.asp, line 39

If cnt = 0  then
Please forgive me for being stupid but the offending code is:
For Each txtUID in Request.Form("txtUID")strBasketID 
Session("BasketID")strItem = Request.Form("txtItem")strPrice 
Request.Form("txtPrice")strQuantity 
Request.Form("txtQuantity")strDatePurchased = date()strSplit 
Request.Form("txtUID")Dim cntif strSplit="" thencnt = 0elseif
isArray(strSplit) thencnt = 2elsecnt = 1end if
strSQL = "SELECT * FROM tblBasket " & _
///this is the line causeing the error If cnt = 0  then  "WHERE BasketID 
'" & strBasketID & "';"End ifIf cnt = 1 then  "WHERE UID = " & strSplit & "
AND BasketID = '" & strBasketID & "';"End if If cnt = 2 then  "WHERE UID IN
(" & strSplit & ") AND BasketID = '" & strBasketID &"';" End if
could you help?
ian
----- Original Message -----
From: "Drew, Ron" <RDrew@B...>
To: "ASP Databases" <asp_databases@p...>
Sent: Thursday, July 11, 2002 2:42 PM
Subject: [asp_databases] RE: For Each loops


OK...have 2 ifs below.  Test the cnt first.
One if would take care of only one update based on cnt = 1.
One if based on cnt = 2..do a split on the strSplit based on a "," and
loop thru the array created by the split to update records.

-----Original Message-----
From: Ian Richardson [mailto:ian@i...]
Sent: Thursday, July 11, 2002 9:30 AM
To: ASP Databases
Subject: [asp_databases] RE: For Each loops


Hi Ron,
Yes each txtUID is a record. The form is a shopping cart and I am trying
to allow users to update the quantities before final submission, so the
form holds the contents of their shopping basket, the basket is
identified by the strBasketID and the item/record to update is
identified by txtUID. Where I have put <input type="hidden"
name="txtUID" value="1"> the actual code for this would be <input
type="hidden" name="txtUID" value="<%=viewbasket("UID")%>">

hth

ian



----- Original Message -----
From: "Drew, Ron" <RDrew@B...>
To: "ASP Databases" <asp_databases@p...>
Sent: Thursday, July 11, 2002 1:07 PM
Subject: [asp_databases] RE: For Each loops


I THINK THIS WILL WORK FOR YOU..BUT NOT SEEING THE FORM ITSELF..THIS MAY
CHANGE..IS EACH txtUID A RECORD IN ITSELF?

strSplit = Request.Form("txtUID")
'-----------------------------
Dim cnt
if strSplit="" then
cnt = 0
elseif isArray(strSplit) then
cnt = 2
else
cnt = 1
end if
'----------------------------
strSQL = "SELECT * FROM tblBasket " &_
If cnt = 0 then
  "WHERE BasketID = '" & strBasketID & "';"
End if
If cnt = 1 then
  "WHERE UID = " & strSplit & " AND BasketID = '" & strBasketID & "';"
End if If cnt = 2 then
  "WHERE UID IN (" & strSplit & ") AND BasketID = '" & strBasketID &
"';" End if

-----Original Message-----
From: Ian Richardson [mailto:ian@i...]
Sent: Thursday, July 11, 2002 6:45 AM
To: ASP Databases
Subject: [asp_databases] For Each loops


Hello

I apologise in advance for this question but I have one of those blocks
that I cannot get my head around. I want to be able to update a database

with new values taken from a form. The form element will have the same
name but different values. For example: <form> <input type="hidden"
name="txtUID" value="1"> <input type="hidden" name="txtUID" value="2">
<input type="hidden" name="txtUID" value="3"> </form>

I wish to be able to loop thro' this collection and take each new value
for txtUID and update the appropriate record, my code is below but I get

the following erro msg:

Microsoft JET Database Engine error '80040e14'
Syntax error (comma) in query expression 'UID = 21, 22 AND BasketID 
'796606393''. /trials/dev/update.asp, line 30

can anybady help me to solve this problem?

many thanks

ian

<%
Set UpdateItem = Server.CreateObject("ADODB.Recordset")
strBasketID = Session("BasketID")

For Each txtUID in Request.Form("txtUID")
strBasketID = Session("BasketID")
strItem = Request.Form("txtItem")
strPrice = Request.Form("txtPrice")
strQuantity = Request.Form("txtQuantity")
strDatePurchased = date()
strSplit = Request.Form("txtUID")
'check for data type
strSQL = "SELECT * FROM tblBasket  WHERE UID =   " & strSplit & "  AND
BasketID = '" & strBasketID  & "'  "
response.write strSQL  & "<br>"
UpdateItem.Open strSQL, con, adOpenStatic, adLockOptimistic
UpdateItem.Update
UpdateItem("BasketID") = Session("BasketID")
UpdateItem("Item") = strItem
UpdateItem("Price") = (strPrice)
UpdateItem("TransactionValue") = (strPrice * strQuantity)
UpdateItem("Quantity") = strQuantity
UpdateItem("DatePurchased") = strDatePurchased UpdateItem.update
response.write strSplit  & "<br>" Next 'response.redirect "basket.asp"
%>
---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 

---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 






Message #7 by "Drew, Ron" <RDrew@B...> on Thu, 11 Jul 2002 09:42:31 -0400
OK...have 2 ifs below.  Test the cnt first.
One if would take care of only one update based on cnt =3D 1.
One if based on cnt =3D 2..do a split on the strSplit based on a "," and
loop thru the array created by the split to update records.

-----Original Message-----
From: Ian Richardson [mailto:ian@i...]
Sent: Thursday, July 11, 2002 9:30 AM
To: ASP Databases
Subject: [asp_databases] RE: For Each loops


Hi Ron,
Yes each txtUID is a record. The form is a shopping cart and I am trying
to allow users to update the quantities before final submission, so the
form holds the contents of their shopping basket, the basket is
identified by the strBasketID and the item/record to update is
identified by txtUID. Where I have put <input type=3D"hidden"
name=3D"txtUID" value=3D"1"> the actual code for this would be <input
type=3D"hidden" name=3D"txtUID" value=3D"<%=3Dviewbasket("UID")%>">

hth

ian



----- Original Message -----
From: "Drew, Ron" <RDrew@B...>
To: "ASP Databases" <asp_databases@p...>
Sent: Thursday, July 11, 2002 1:07 PM
Subject: [asp_databases] RE: For Each loops


I THINK THIS WILL WORK FOR YOU..BUT NOT SEEING THE FORM ITSELF..THIS MAY
CHANGE..IS EACH txtUID A RECORD IN ITSELF?

strSplit =3D Request.Form("txtUID")
'-----------------------------
Dim cnt
if strSplit=3D"" then
cnt =3D 0
elseif isArray(strSplit) then
cnt =3D 2
else
cnt =3D 1
end if
'----------------------------
strSQL =3D "SELECT * FROM tblBasket " &_
If cnt =3D 0 then
  "WHERE BasketID =3D '" & strBasketID & "';"
End if
If cnt =3D 1 then
  "WHERE UID =3D " & strSplit & " AND BasketID =3D '" & strBasketID & 
"';"
End if If cnt =3D 2 then
  "WHERE UID IN (" & strSplit & ") AND BasketID =3D '" & strBasketID &
"';" End if

-----Original Message-----
From: Ian Richardson [mailto:ian@i...]
Sent: Thursday, July 11, 2002 6:45 AM
To: ASP Databases
Subject: [asp_databases] For Each loops


Hello

I apologise in advance for this question but I have one of those blocks
that I cannot get my head around. I want to be able to update a database

with new values taken from a form. The form element will have the same
name but different values. For example: <form> <input type=3D"hidden"
name=3D"txtUID" value=3D"1"> <input type=3D"hidden" name=3D"txtUID" 
value=3D"2">
<input type=3D"hidden" name=3D"txtUID" value=3D"3"> </form>

I wish to be able to loop thro' this collection and take each new value
for txtUID and update the appropriate record, my code is below but I get

the following erro msg:

Microsoft JET Database Engine error '80040e14'
Syntax error (comma) in query expression 'UID =3D 21, 22 AND BasketID 
=3D
'796606393''. /trials/dev/update.asp, line 30

can anybady help me to solve this problem?

many thanks

ian

<%
Set UpdateItem =3D Server.CreateObject("ADODB.Recordset")
strBasketID =3D Session("BasketID")

For Each txtUID in Request.Form("txtUID")
strBasketID =3D Session("BasketID")
strItem =3D Request.Form("txtItem")
strPrice =3D Request.Form("txtPrice")
strQuantity =3D Request.Form("txtQuantity")
strDatePurchased =3D date()
strSplit =3D Request.Form("txtUID")
'check for data type
strSQL =3D "SELECT * FROM tblBasket  WHERE UID =3D   " & strSplit & "  
AND
BasketID =3D '" & strBasketID  & "'  "
response.write strSQL  & "<br>"
UpdateItem.Open strSQL, con, adOpenStatic, adLockOptimistic
UpdateItem.Update
UpdateItem("BasketID") =3D Session("BasketID")
UpdateItem("Item") =3D strItem
UpdateItem("Price") =3D (strPrice)
UpdateItem("TransactionValue") =3D (strPrice * strQuantity)
UpdateItem("Quantity") =3D strQuantity
UpdateItem("DatePurchased") =3D strDatePurchased UpdateItem.update
response.write strSplit  & "<br>" Next 'response.redirect "basket.asp"
%>
---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 

---
Change your mail options at http://p2p.wrox.com/manager.asp or to
unsubscribe send a blank email to 



Message #8 by "Ian Richardson" <ian@i...> on Thu, 11 Jul 2002 14:30:08 +0100
Hi Ron,
Yes each txtUID is a record. The form is a shopping cart and I am trying to
allow users to update the quantities before final submission, so the form
holds the contents of their shopping basket, the basket is identified by the
strBasketID and the item/record to update is identified by txtUID. Where I
have put
<input type="hidden" name="txtUID" value="1"> the actual code for this would
be
<input type="hidden" name="txtUID" value="<%=viewbasket("UID")%>">

hth

ian



----- Original Message -----
From: "Drew, Ron" <RDrew@B...>
To: "ASP Databases" <asp_databases@p...>
Sent: Thursday, July 11, 2002 1:07 PM
Subject: [asp_databases] RE: For Each loops


I THINK THIS WILL WORK FOR YOU..BUT NOT SEEING THE FORM ITSELF..THIS MAY
CHANGE..IS EACH txtUID A RECORD IN ITSELF?

strSplit = Request.Form("txtUID")
'-----------------------------
Dim cnt
if strSplit="" then
cnt = 0
elseif isArray(strSplit) then
cnt = 2
else
cnt = 1
end if
'----------------------------
strSQL = "SELECT * FROM tblBasket " &_
If cnt = 0 then
  "WHERE BasketID = '" & strBasketID & "';"
End if
If cnt = 1 then
  "WHERE UID = " & strSplit & " AND BasketID = '" & strBasketID & "';"
End if
If cnt = 2 then
  "WHERE UID IN (" & strSplit & ") AND BasketID = '" & strBasketID &
"';"
End if

-----Original Message-----
From: Ian Richardson [mailto:ian@i...]
Sent: Thursday, July 11, 2002 6:45 AM
To: ASP Databases
Subject: [asp_databases] For Each loops


Hello

I apologise in advance for this question but I have one of those blocks
that I cannot get my head around. I want to be able to update a database

with new values taken from a form. The form element will have the same
name but different values. For example:
<form>
<input type="hidden" name="txtUID" value="1">
<input type="hidden" name="txtUID" value="2">
<input type="hidden" name="txtUID" value="3">
</form>

I wish to be able to loop thro' this collection and take each new value
for txtUID and update the appropriate record, my code is below but I get

the following erro msg:

Microsoft JET Database Engine error '80040e14'
Syntax error (comma) in query expression 'UID = 21, 22 AND BasketID
= '796606393''.
/trials/dev/update.asp, line 30

can anybady help me to solve this problem?

many thanks

ian

<%
Set UpdateItem = Server.CreateObject("ADODB.Recordset")
strBasketID = Session("BasketID")

For Each txtUID in Request.Form("txtUID")
strBasketID = Session("BasketID")
strItem = Request.Form("txtItem")
strPrice = Request.Form("txtPrice")
strQuantity = Request.Form("txtQuantity")
strDatePurchased = date()
strSplit = Request.Form("txtUID")
'check for data type
strSQL = "SELECT * FROM tblBasket  WHERE UID =   " & strSplit & "  AND
BasketID = '" & strBasketID  & "'  "
response.write strSQL  & "<br>"
UpdateItem.Open strSQL, con, adOpenStatic, adLockOptimistic
UpdateItem.Update
UpdateItem("BasketID") = Session("BasketID")
UpdateItem("Item") = strItem
UpdateItem("Price") = (strPrice)
UpdateItem("TransactionValue") = (strPrice * strQuantity)
UpdateItem("Quantity") = strQuantity
UpdateItem("DatePurchased") = strDatePurchased UpdateItem.update
response.write strSplit  & "<br>" Next 'response.redirect "basket.asp"
%>



Message #9 by "Drew, Ron" <RDrew@B...> on Thu, 11 Jul 2002 08:07:02 -0400
I THINK THIS WILL WORK FOR YOU..BUT NOT SEEING THE FORM ITSELF..THIS MAY
CHANGE..IS EACH txtUID A RECORD IN ITSELF?

strSplit =3D Request.Form("txtUID")
'-----------------------------
Dim cnt
if strSplit=3D"" then
	cnt =3D 0
elseif isArray(strSplit) then
	cnt =3D 2
else
	cnt =3D 1
end if
'----------------------------
strSQL =3D "SELECT * FROM tblBasket " &_
If cnt =3D 0 then
  "WHERE BasketID =3D '" & strBasketID & "';"
End if
If cnt =3D 1 then
  "WHERE UID =3D " & strSplit & " AND BasketID =3D '" & strBasketID & 
"';"
End if
If cnt =3D 2 then
  "WHERE UID IN (" & strSplit & ") AND BasketID =3D '" & strBasketID &
"';"
End if

-----Original Message-----
From: Ian Richardson [mailto:ian@i...]
Sent: Thursday, July 11, 2002 6:45 AM
To: ASP Databases
Subject: [asp_databases] For Each loops


Hello

I apologise in advance for this question but I have one of those blocks
that I cannot get my head around. I want to be able to update a database

with new values taken from a form. The form element will have the same
name but different values. For example:
<form>
<input type=3D"hidden" name=3D"txtUID" value=3D"1">
<input type=3D"hidden" name=3D"txtUID" value=3D"2">
<input type=3D"hidden" name=3D"txtUID" value=3D"3">
</form>

I wish to be able to loop thro' this collection and take each new value
for txtUID and update the appropriate record, my code is below but I get

the following erro msg:

Microsoft JET Database Engine error '80040e14'
Syntax error (comma) in query expression 'UID =3D 21, 22 AND BasketID
=3D '796606393''.
/trials/dev/update.asp, line 30

can anybady help me to solve this problem?

many thanks

ian

<%
Set UpdateItem =3D Server.CreateObject("ADODB.Recordset")
strBasketID =3D Session("BasketID")

For Each txtUID in Request.Form("txtUID")
strBasketID =3D Session("BasketID")
strItem =3D Request.Form("txtItem")
strPrice =3D Request.Form("txtPrice")
strQuantity =3D Request.Form("txtQuantity")
strDatePurchased =3D date()
strSplit =3D Request.Form("txtUID")
'check for data type
strSQL =3D "SELECT * FROM tblBasket  WHERE UID =3D   " & strSplit & "  
AND
BasketID =3D '" & strBasketID  & "'  "
response.write strSQL  & "<br>"
UpdateItem.Open strSQL, con, adOpenStatic, adLockOptimistic
UpdateItem.Update
UpdateItem("BasketID") =3D Session("BasketID")
UpdateItem("Item") =3D strItem
UpdateItem("Price") =3D (strPrice)
UpdateItem("TransactionValue") =3D (strPrice * strQuantity)
UpdateItem("Quantity") =3D strQuantity
UpdateItem("DatePurchased") =3D strDatePurchased UpdateItem.update
response.write strSplit  & "<br>" Next 'response.redirect "basket.asp"
%>
Message #10 by "Ian Richardson" <ian@i...> on Thu, 11 Jul 2002 10:45:25
Hello

I apologise in advance for this question but I have one of those blocks 
that I cannot get my head around. I want to be able to update a database 
with new values taken from a form. The form element will have the same 
name but different values. For example:
<form>
<input type="hidden" name="txtUID" value="1">
<input type="hidden" name="txtUID" value="2">
<input type="hidden" name="txtUID" value="3">
</form>

I wish to be able to loop thro' this collection and take each new value 
for txtUID and update the appropriate record, my code is below but I get 
the following erro msg:

Microsoft JET Database Engine error '80040e14' 
Syntax error (comma) in query expression 'UID = 21, 22 AND BasketID 
= '796606393''. 
/trials/dev/update.asp, line 30 

can anybady help me to solve this problem?

many thanks

ian

<%
Set UpdateItem = Server.CreateObject("ADODB.Recordset")
strBasketID = Session("BasketID")

For Each txtUID in Request.Form("txtUID")
strBasketID = Session("BasketID")
strItem = Request.Form("txtItem")
strPrice = Request.Form("txtPrice")
strQuantity = Request.Form("txtQuantity")
strDatePurchased = date()
strSplit = Request.Form("txtUID")
'check for data type
strSQL = "SELECT * FROM tblBasket  WHERE UID =   " & strSplit & "  AND 
BasketID = '" & strBasketID  & "'  " 
response.write strSQL  & "<br>"
UpdateItem.Open strSQL, con, adOpenStatic, adLockOptimistic
UpdateItem.Update
UpdateItem("BasketID") = Session("BasketID")
UpdateItem("Item") = strItem
UpdateItem("Price") = (strPrice)
UpdateItem("TransactionValue") = (strPrice * strQuantity)
UpdateItem("Quantity") = strQuantity
UpdateItem("DatePurchased") = strDatePurchased
UpdateItem.update
response.write strSplit  & "<br>"
Next
'response.redirect "basket.asp"
%>

  Return to Index