Insert Syntax question for field names in the value portion of the command.

M

Matthew Ferri

Hi,

I'm using Windows 2000 SP4 with Office 2000 Pro SP3.

I'm trying to add a new record to a Microsoft Access 2000 database from
within a VBScript
ASP segment of my web page. I'm having trouble generating the proper syntax
for the "Insert" command within Microsoft Access 2000. I can find the Insert
commands that use the actual field values within the second half of the
command, but I think I need to use field names for the ASP fields that will
be used in this new record.

I'm using the command format "Insert into table (field1, field2) values
(field1, field2)"

The closest Technet article I could find is Q175770, but that did not help
me enough.

I could find the MSDN articles that tell me how to insert the actual values
themselves into the record, but I think I need to use the field names for
the ASP fields within the "
"values" portion of the Insert command for my VBScript ASP segment.

Thanks in Advance.
Matthew
 
R

Rob

The SQL instruction you run from ASP needs to be the
complete SQL command, with the data values already present
it ASCII form.

The first part of you command is correct:

strSQL = "Insert into table (field1, field2) values ("

and to that string you need to append the values collected
from your form, like:

strSQL = strSQL & Request.Form("field1") & ", "
strSQL = strSQL & Request.Form("field2") & ")"

Then execute the strSQL instruction.

You may also need to add delimiters if you are dealing
with string or date values, as in:
... values ('" & field1 & "',"

HTH

Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top