PDA

View Full Version : Help in value in Request.Form


Thimo
10-30-2002, 02:56 PM
hi, those who replied to my previous threads should have a better idea what i am going to say...

<%
Dim whereClause, rs

For Each Item in Request.Form("add")
If whereClause <> "" then
whereClause = whereClause & "OR ItemID=" & item
Else
whereClause = "ItemID=" & item
End If
Next

strSQL = "SELECT * FROM Item WHERE " & whereClause
set rs = objConn.Execute(strSQL)
%>

<%
Do until rs.EOF
dim rs2
Set rs2 = Server.CreateObject("ADODB.Recordset")
rs2.AddNew
rs2("ItemName") = rs("ItemName")
rs2("ItemCode") = rs("ItemCode")
rs2("Price") = rs("Price")
rs2("RQuantity") = Request.Form("RQty")
rs2.Update
rs.MoveNext
loop
%>

<%
Dim display, rs3
display = "SELECT * FROM Staff"
set rs3 = objConn.Execute(display)
%>

<form>
<table border="1" align="center">
<tr>
<th height="25">Item Code</th>
<th>ItemName</th>
<th>Requested Quantity</th>
<th>Price</th>
</tr>
<%Do While Not rs.EOF%>
<tr align=center>
<td><%=rs3("ItemCode")%></td>
<td align=left><%=rs3("ItemName")%></td>
<td><%rs3("RQuantity")%></td>
<td><%=FormatCurrency(rs("Price"))%></td>
<tr>
<%rs.MoveNext%>
<%loop%>
</table>
<p>&nbsp;</p>
<center>

</center>
</form>
</body>
</html>

to summarise the problem...actually is my Request.Form("RQty") has an array of values, how do i corresspond it like ...when the user enter for example...

Item 1 , RQty = 10
Item 1 , RQty = 20

the value i get in Request.Form is an array of value which is 10, 20

is there anyway i can break up the array?

thanks..btw this is the error msg i received...

Error Type:
ADODB.Recordset (0x800A0E78)
Operation is not allowed when the object is closed.
/asp/DisplayCart.asp, line 35

Page:
POST 41 bytes to /asp/DisplayCart.asp

POST Data:
RQty=1&Qty=1000&add=6&RQty=1&Qty=50&add=7

mark wills
10-30-2002, 05:07 PM
Do you not need the Split function?

I.e. if you have a string like this:
Mystring="1,2,3,4,5"

Then:

MyArray=Split(MyString,",")

Would give you each part of the string in an element:

MyArray(0)="1"
MyArray(1)="2"
MyArray(2)="3"

etc

Hope I have mis-understood you! Apologies if this it total rubbish!

Mark.

Thimo
10-31-2002, 12:55 PM
looks like there is not such function......

spilt(MyString ,",")

allida77
10-31-2002, 01:13 PM
sure there is:

Split() dev guru (http://www.devguru.com/Technologies/vbscript/quickref/split.html)

Or

split() W3schools (http://www.w3schools.com/vbscript/func_split.asp)

Can you post the error or code you have when using this function?

whammy
11-02-2002, 12:57 AM
Something looks funny to me about your connections and recordsets in the first place, since that's definitely not the way I learned to code them, although I've seen them done that way, and if anything I think it's confusing... but this error:

Error Type:
ADODB.Recordset (0x800A0E78)
Operation is not allowed when the object is closed.
/asp/DisplayCart.asp, line 35

sounds like you're working with a recordset object that no longer exists, because you've closed the recordset object.

It's very confusing when you try to keep a bunch of recordsets open when you don't have to, and name them very similarly...

I usually use one... "rs", and redefine it as I go along (unless I actually NEED to use two recordsets at the same time).

To be honest, I'm not really sure if it's the best way to do it, but everything I have done using that method seems to run a bit faster and hasn't produced any errors to date...