|
|
|
|
|
| | |
|
Active Server Pages asp source code database MS SQL MS Access .mdb adovbs.inc cookies calendar codes sql commands scripts asp programming tutorials iis web server components CJWSoft ASPProtect ASPBanner ASPClassifieds
(Advanced)
(Components)
(Database)
(General)
(Vbscript)

|
|
Subject: |
Updating Database with a Loop? |
From: |
Scott Stevens |
Date: |
2/1/2001 1:15:35 AM |
IP: |
198.143.232.136 |
I have a page with many input fields, after hitting "Continue", the next page has asp code to write the previous values to a database. Since there are so many input fields, I would like to create a new record and input the data using a loop command, however the following code keeps giving me errors.
<%
' declaring variables
' not neccesary but a good habit
Dim DataConn
Dim CmdAddRecord
Dim MYSQL
Set DataConn = Server.CreateObject("ADODB.Connection")
Set CmdAddRecord = Server.CreateObject("ADODB.Recordset")
DataConn.Open "DSN=employment"
MYSQL = "SELECT application.* FROM application"
CmdAddRecord.Open MYSQL, DataConn, 1, 3
CmdAddRecord.AddNew
FOR EACH el IN Request.Form
CmdAddRecord.Fields(el) = Request.Form(el)
NEXT
CmdAddRecord.Update
CmdAddRecord.Close
Set CmdAddRecord = Nothing
DataConn.Close
Set DataConn = Nothing
%>
Am I trying to use the "AddNew" feature incorrectly? Is there a way to process all the elements in a form, without writing them all out?
Thanks for your help. |
|
|

|
|
|
|
|
|
|
|
|
|