|
 |
asp_web_howto thread: Adding multiple records with one submission
Message #1 by "Paul David Jacobs" <jacobspd@g...> on Fri, 21 Feb 2003 16:43:48 -0600
|
|
Hi all,
I am trying to build a web page that can put "stock" into a database.
The user can enter a specific item with description. However, the same
product has a different serial number for each box. So for example if I
want to add 3 boxes of the same product you will have 3 serial numbers.
I have decided to make a separate database table that contains only the
serial numbers and a reference number and this has a internal
relationship to the main stock database. I want to arrange them as
follow in the database:
Reference No. | Serial
485978 | 6513546813216
485978 | 3215651351645
485978 | 6546532154548
Then I can just call the entries with the relevant reference number.
However the problem comes when I try to add multiple record with one
form submittal. The user at the top of the page specifies the number
purchased for stock. He then submits the page to itself and if displays
the appropriate number of serial number boxes in different records. I
want to enter these into the database table on one click.
I am trying the following code:
However the script does not enter the data into the database:
xcnt =3D 1
FOR iSerialCounter =3D 1 TO varQuantity
Set rt=3DServer.CreateObject("ADODB.Recordset")
rt.Open "Serials", "DSN=3Dsii", adOpenKeyset, adLockOptimistic
rt.AddNew
rt.Fields("FolioNumber") =3D varFolio
rt.Fields("Serie") =3D Request.Form("serial"" & xcnt & """)
rt.Update
rt.Close
xcnt =3D xcnt + 1
NEXT
VarQuantity is a variable introduced at the beginning which is a number
specified by the user for the amount of serial number boxes required.
VarFolio is the reference number
I would like to know what I am doing wrong as I can't seem to get the
code to work properly. If there is a better way to layout the database
or enter the data into the dbase then I am open to suggestions to
improve my code.
With many thanks for all your assistance and time,
Paul D. Jacobs
Web Applications Developer and Information Systems Manager
jacobspd@g...
_____
Servicios Interactivos Internacionales S.A. de C.V.
Via Ceti #56, Fracc Luis Enrique Erro,
Planetario Lindavista,
C.P 07730
M=E9xico D.F.
Message #2 by "Manhal M Shukayr" <mshukayr@r...> on Fri, 21 Feb 2003 16:54:07 -0600
|
|
I would just open the recordset one time and then loop thru the add
Set rt=Server.CreateObject("ADODB.Recordset")
rt.Open "Serials", "DSN=sii", adOpenKeyset, adLockOptimistic
FOR iSerialCounter = 1 TO varQuantity
rt.AddNew
rt.Fields("FolioNumber") = varFolio
rt.Fields("Serie") = Request.Form("serial"" & xcnt & """)
rt.Update
NEXT
rt.Close
xcnt = xcnt + 1
Manhal M Shukayr
mshukayr@r...
www.river-cities.com
River Cities Software
----- Original Message -----
From: "Paul David Jacobs" <jacobspd@g...>
To: "ASP Web HowTo" <asp_web_howto@p...>
Sent: Friday, February 21, 2003 4:43 PM
Subject: [asp_web_howto] Adding multiple records with one submission
Hi all,
I am trying to build a web page that can put "stock" into a database.
The user can enter a specific item with description. However, the same
product has a different serial number for each box. So for example if I
want to add 3 boxes of the same product you will have 3 serial numbers.
I have decided to make a separate database table that contains only the
serial numbers and a reference number and this has a internal
relationship to the main stock database. I want to arrange them as
follow in the database:
Reference No. | Serial
485978 | 6513546813216
485978 | 3215651351645
485978 | 6546532154548
Then I can just call the entries with the relevant reference number.
However the problem comes when I try to add multiple record with one
form submittal. The user at the top of the page specifies the number
purchased for stock. He then submits the page to itself and if displays
the appropriate number of serial number boxes in different records. I
want to enter these into the database table on one click.
I am trying the following code:
However the script does not enter the data into the database:
xcnt = 1
FOR iSerialCounter = 1 TO varQuantity
Set rt=Server.CreateObject("ADODB.Recordset")
rt.Open "Serials", "DSN=sii", adOpenKeyset, adLockOptimistic
rt.AddNew
rt.Fields("FolioNumber") = varFolio
rt.Fields("Serie") = Request.Form("serial"" & xcnt & """)
rt.Update
rt.Close
xcnt = xcnt + 1
NEXT
VarQuantity is a variable introduced at the beginning which is a number
specified by the user for the amount of serial number boxes required.
VarFolio is the reference number
I would like to know what I am doing wrong as I can't seem to get the
code to work properly. If there is a better way to layout the database
or enter the data into the dbase then I am open to suggestions to
improve my code.
With many thanks for all your assistance and time,
Paul D. Jacobs
Web Applications Developer and Information Systems Manager
jacobspd@g...
_____
Servicios Interactivos Internacionales S.A. de C.V.
Via Ceti #56, Fracc Luis Enrique Erro,
Planetario Lindavista,
C.P 07730
México D.F.
|
|
 |