Scott said:
Just as a side note, I've found this technique very useful for
populating a table on a database - as long as the field names in the
table are the same as the form object names,
And the datatypes cooperate ....
it's as easy as:
[set up your connection, recordset, etc]
RS.AddNew
For Each Item In Request.Form
RS(Item) = Request.Form(Item)
Next
RS.Update
I find it's a good way to populate a table with a kajillion different
fields from a table with a kajillion different fields, in essentially
3 lines of code.
It's great for the coder - not so good for the application performance and
scalability. Cursors should not be used for data maintenance. How about
this:
sSQLi = "INSERT INTO table ("
sSQLv = " VALUES("
for each Item In Request.Form
sSQLi = sSQLi & Item & ","
'you will need logic here to handle various datatypes
Select Case datatype
Case "Text"
sSQLv= sSQLv & "'" & Replace(Request.Form(Item),"'","''") & "',"
Case "Number"
sSQLv= sSQLv & Replace(Request.Form(Item),"'","''") & ","
Case "Date"
sSQLv= sSQLv & "#" & Replace(Request.Form(Item),"'","''") & "#,"
Next
'get rid of the trailing commas
sSQLi = Left(sSQLi,len(sSQLi) - 1) & ")"
sSQLv = Left(sSQLv,len(sSQLv)-1) & ")"
sSQL = sSQLi & sSQLv
Response.write sSQL
conn.Execute ,,129
Now you've had to write a little more code, but, now you've handled all the
chores that ADO needs to do behind the scenes anyways when updating a
recordset. Pluse you've eliminated the need to open an expensive updatable
cursor.
Bob Barrows