Click to See Complete Forum and Search --> : Creation of Recordset


Niloo
August 27th, 2000, 04:57 PM
hello,
I am creating empty recordset and inserting fields and data at runtime from the form(Drop-down list box). It is working file with VB but not with ASP.
I am not able to insert data from HTML form to Recordset. It gives me recordcount etc. i am using keyset with optimistic lock type.
e.g.
with rstmp
.addnew
rstmp(0) = i
rstmp(1) = request.form("lsttmp").item(i)
.update
end with
If any one knows regarding this problem then pls. help me.
I tried it many times with different approach but not successful.

Johnny101
August 28th, 2000, 11:18 AM
This line here is the problem, i suspect:

rstmp(1) = request.form("lsttmp").item(i)

the html list box only returns the value selected. also, request.form("lsttmp") is all you need to get this value. since the item's index could be 0 or 1, i guess you could test for both, asking for the .item(index) is risky. the only way i can see the above line of code working is if the html list box is a "multi-select" list box and you are looping through the collection.here's a working example of what i'm talking about:

<body>
<% if request.querystring("action") = "do" then
dim i
response.write "Your First Name is " & request.form("txtfirstname") & "
"
for i = 1 to request.form("lsttmp").count
response.write i & " - " & request.form("lsttmp").item(i) & "
"
next
else%>

<select name="lsttmp" multiple>
&lt;option>first</option>
&lt;option>second</option>
&lt;option>third</option>
&lt;option>fourth</option>
&lt;/select>

&lt;input type=text name=txtfirstname>




&lt;/body>
&lt;/html>




in your case, building the recordset, here's some untested code that does what the above does, but instead puts in the recordset:

&lt;% if request.querystring("action") = "do" then
dim i
for i = 1 to request.form("lsttmp").count
rsTemp(0) = i
rsTemp(1) = request.form("lsttmp").item(i)
next

...



that way, if there's only one entry selected, it will get it, if there's more, it will get those as well.

hope this helps,

John

John Pirkey
MCSD
http://www.ShallowWaterSystems.com
http://www.stlvbug.org