Insert Into Sql table help

Amjad

Perch
I am able to read from the table using my db connection
but when i want to insert fields into the table i get this error:

Microsoft OLE DB Provider for SQL Server error '80040e14'

Incorrect syntax near the keyword 'Set'.

/process.asp, line 53


Set NewCust = db.execute ("INSERT INTO custtable Set " &_
"fname = 'FirstName'" &_
"lname = 'LastName'" &_
"email = 'EmailAddress'" &_
"address1 = 'Any Address'" &_
"address2 = 'N/a'" &_
"city = 'City'" &_
"state = 'State'" &_
"zip = 'Zip'" &_
"country = 'USA'" &_
"phone = '4456544665'" )


Any Thoughts? I have the same exact code running for another website on another server but using MySQL instead of MSSQL. Thanks for any help.

Amjad
 
I'm not an ASP expert at all, but in SQL, I think you need commas after each item you set the value of. For instance:

Set NewCust = db.execute ("INSERT INTO custtable Set " &_
"fname = 'FirstName'," &_
"lname = 'LastName'," &_
"email = 'EmailAddress'," &_
"address1 = 'Any Address'," &_
"address2 = 'N/a'," &_
"city = 'City'," &_
"state = 'State'," &_
"zip = 'Zip'," &_
"country = 'USA'," &_
"phone = '4456544665'" )
 
Use this:

Code:
Set NewCust = db.execute("INSERT INTO custtable(fname, lname, email, " &_
" address1, address2, city, state, zip, country, phone) VALUES ('FirstName'," &_
" 'LastName', '[email protected]', 'Any Address', 'N/a', 'City',  " &_
" 'State', 'Zip', 'USA', '4456544665')"
 
INSERT INTO VALUES or SELECT????

I have a quite difficult problem and I need help!!!!

I have a table and I have to insert a few hundred rows with these columns:

Email
When
What

I could make when and what with VALUES like

INSERT INTO emaillog(when, what)
VALUES (050712,P:\db\RAM Price List 070512.zip)

This is okay. The problem is with the emails. Those come from a query, I have a few thousand. So the new rows should look like this:

[email protected] 050712 P:\db\RAM Price List 070512.zip
[email protected] 050712 P:\db\RAM Price List 070512.zip
[email protected] 050712 P:\db\RAM Price List 070512.zip
[email protected] 050712 P:\db\RAM Price List 070512.zip
[email protected] 050712 P:\db\RAM Price List 070512.zip
[email protected] 050712 P:\db\RAM Price List 070512.zip
...

I really don't know how to do that...

I tried...
INSERT INTO emaillog(email, when, what)
VALUES (

(SELECT email FROM ram_070515query), 050712, P:\db\RAM Price List 070512.zip)...

but it didn't work...

PLEASE HELP ME, I don't want to type in hundreds of rows!!!!
 
Back
Top