Forums

ASP

This topic is locked

Insert Into request.form

Posted 20 Apr 2002 13:03:30
1
has voted
20 Apr 2002 13:03:30 Tom Ka posted:
Hello

I want to insert records into a accessDB.
The data is comming form a form where I have a single value linkID and multiple values katID.
The katID values can vary in the ammounts (it can be just one or many)
For each value in katID I want to insert a record in the DB
If the Form got submittet with LinkID=123 and with katid=1&katid=20&katid=30
the DB should have 3 new lines in two columns as follows:
col1 | col2
123 | 1
123 | 20
123 | 30

If the Form got submittet with LinkID=123 and with katid=1 it should have only one new record:
col1 | col2
123 | 1

I know how to create all the DBconnection, open, insert...
but I'm hanging to build the sql-string in combination with the request.form!

can someone help me please?
Thanks
Tom

Replies

Replied 30 Apr 2002 18:39:12
30 Apr 2002 18:39:12 johannes nel replied:
there r several ways of doing this kind of thing, the most elegant being a xml based solution, but i presume u don't want that.

here is my advice:
this is wrong!!
LinkID=123 and with katid=1&katid=20&katid=30
querystrings travel in value pairs with a key..
the key here is catID, and it occurs 3 time thus catID on the .asp page being posted to will only receive linkID=123&catID=30

i presume you are adding these catID's on the client, with multiple catID's {potentially} being generated between posts to the server.
(hope this is still clear! ;] )

U don't know how many catID's the client will be adding to against LinkID

I advise you to trap all these catID in a single string and delimanating them

example: catIDString = ""
then client adds 3 catID's
then catIDString = "20 | 30 | 1"

store this in a hiddenfield ...
the info is sent using querystrings as before== linkID=123CatId=1|20|30

when it gets to the server...
<% dim arr
arr= split(request.querystring(catID,"|")
and kaboom you have an array with the cat id's in

no just loop through the array

dim i
for i = lbound(arr) to ubound(arr)
rs!catID=arr(i)
rs!LinkID=request.querystring("LinkID"
rs.update
next


hope this helps otherwise post again...

ps. udzone staff please make the box where i type my reply larger!

Reply to this topic