SAVEREC.ASP
1.The file saverec.asp retrieves information entered
by the user and saves it to the database
table pals.
2.The general SQL INSERT statement below retrieves and saves a new record.
INSERT MyTable (mycolumns
list) VALUES (myvalues list)
To save the
entry Tom Cruise into table pals, our SQL statement is
INSERT pals (fname, lname) Values ('Tom', 'Cruise')
The values Tom and Cruise are enclosed in single quotes since these are string values.
<%SQLSave = "INSERT pals (fname, lname) VALUES ('"%>
<%SQLSave = SQLSave & Request.Form("fname")%>
<%SQLSave = SQLSave & "', '"%>
<%SQLSave = SQLSave & Request.Form("lname")%>
<%SQLSave = SQLSave & "')"%>
4.However, if you write down each line of code (ignoring all
<% and %> and double quotes save for "fname" and "lname"), and then put them together,
they add up to the SQL INSERT statement above which saves Tom Cruise into table
pals.
5.For example, the first line translates to: INSERT pals (fname,
lname) Values ('
6.The last line translates to: ')
7.The <% %> pair tells the file processor that the code within is script code, not HTML code.