I have a primary key column called 'ID' in my Access database table which is of type autonumber. I am trying to collect data from a form and insert it into the DB table. In the INSERT INTO command of my ASP, I do not have the ID column, do I need to add this to my code, or is it dealt with Automatically? Code:
mySQL= "INSERT INTO webdatabase "
mySQL= mySQL & "(SchoolName,NameofContact,Address1,Address2,Address3,Country,TelephoneNumber,FaxNumber,Email,Website ,AgeofChildren,numberofchildren, PurposeofVisit,TryScuba,ScubaRangers,Snorkeling,DiveCourse,TransporttoTanjungLeman,PreferredMenu,Spe cialRequirements/Comments) "
mySQL= mySQL & "VALUES ('" & Request.Form("SchoolName") & "','"
mySQL= mySQL & Request.Form("NameOfContact") & "'"
mySQL= mySQL & ",'" & Request.Form("Address1") & "'"
mySQL= mySQL & ",'" & Request.Form("Address2") & "','"
mySQL= mySQL & Request.Form("Address3") & "','"
mySQL= mySQL & Request.Form("Country") & "')"
mySQL= mySQL & Request.Form("TelephoneNumber") & "')"
mySQL= mySQL & Request.Form("FaxNumber") & "')"
mySQL= mySQL & Request.Form("Email") & "')"
mySQL= mySQL & Request.Form("Website") & "')"
mySQL= mySQL & Request.Form("AgeOfChildren") & "')"
mySQL= mySQL & Request.Form("NumberOfChildren") & "')"
mySQL= mySQL & Request.Form("PurposeOfVisit") & "')"
mySQL= mySQL & Request.Form("TryScuba") & "')"
mySQL= mySQL & Request.Form("ScubaRangers") & "')"
mySQL= mySQL & Request.Form("Snorkeling") & "')"
mySQL= mySQL & Request.Form("DiveCourse") & "')"
mySQL= mySQL & Request.Form("TransportToTL") & "')"
mySQL= mySQL & Request.Form("PreferredMenu") & "')"
mySQL= mySQL & Request.Form("SpecialRequirements") & "')"
cmelnick
06-12-2003, 10:41 AM
Sorry, don't mean to be picky, but you could also clean this code up a bunch and save a couple CPU cycles... You can donate them to needy kids in China :D
Not really necessary or anything, but I have done a lot of large programming projects, and the nicer your code is to read, the easier it is to do EVERYTHING else... Might be a waste of your time, but I like it. It just ends up being a lot easier to track down errors if you can quickly and easily match up name and value pairs.
%>
<p><font face="Verdana" color="#FF0000"><b>Thank you for submitting your
information!<br>
</b></font><font face="Verdana" size="2">You will receive an e-mail
shortly. The e-mail was sent using the following information:</font></p>
<b><font face="Verdana" size="2">Sent To: <%
Response.Write Request.Form("EMail")
%>
<br>
From : Microsoft PSS Sample Page</font>
<p><font face="Verdana" size="2">Subject: Send to Database and E-mail</font></p>
<p><font face="Verdana" size="2">Content: <%
Response.Write(ParseBody(strBody))
Hi, tried the code above but have hit another problem, get this error message when I run the code:
ADODB.Recordset error '800a0bb9'
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
/Email.asp, line 14
Line 14 is:
myRecordSet.Open mySQL, myConnection, 2, 3
grizla
06-15-2003, 09:47 AM
Ok, I will have a look at that, thank you very much for all of your help!
Grizla
grizla
06-15-2003, 09:14 PM
Ok, hopefully this will be the last thing I need, but do i put the quotes in the SQL statement here, If so where do they go? I only have character and numeric data, I also have a field ID, which is the PK and is an autonumber but I presume this will be dealt with automatically: