This page takes each component of the the new_tran2.asp page and
inserts it into the components table. The trick is traversing the
request collection since the number of request items can be
different for any transaction. Also the submit and reset buttons are
part of the collection sent to this page, so we must make sure we
have logic to handle or else they will be inserted into the
database.
NEW
TRANSACTION
Set count =
Server.CreateObject(“ADODB.Connection”)
DB_PATH =
SERVER.MAPPATH(“/DB”)
CONNECT_STR = “FILEDSN=” &
DB_PATH & “DB.DSN;” & _
“DBQ=” & DB_PATH &
“WEBDB.MDB;”
count.Open CONNECT_STR ‘get a connection to the db
set countrs =
Server.CreateObject(“ADODB.RecordSet”)
NBR_OF_ITEM = 0
‘every 3 items makes one
component
For Each item In
Request.Form() ‘traverse the
Request items
if (item
“B1”) AND (item “B2”) then ‘dont process the buttons
NBR_OF_ITEM = NBR_OF_ITEM +
1
IF
MID(ITEM,1,1) = “N”
THEN
MY_NAME =
(request.form(item))
ELSE
IF
MID(ITEM,1,1) = “P”
THEN
MY_POSITION = (request.form(item))
ELSE
MY_LENGTH = request.form(item)
END
IF
IF
NBR_OF_ITEM = 3
THEN
NBR_OF_ITEM = 0
END
IF
END IF
‘every 3 items do an insert into
components
IF NBR_OF_ITEM = 0
THEN
SQL = “INSERT INTO COMPONENTS (TR_TRAN_ID, TR_POSITION, ” & _
“TR_LENGTH,” &
_
“TR_NAME) VALUES (” & SESSION(“NEW_TRAN_ID”) & “, ” &
_
MY_POSITION & “, ” & MY_LENGTH &”, ‘” & MY_NAME
& “‘)”
countrs.Open sql, count, 3 , 3,
1
END
IF
END
IF
Next
%>
COMPONENTS HAVE BEEN
ADDED!
Working
example