I am getting the following error when trying to insert form data into an
Access db:
80040e14|[Microsoft][ODBC_Microsoft_Access_Driver]_Syntax_error_in_string_in_query_expression_''++++_)'. 500
I've traced it down to the following code:
'insert records into db
Set con = Server.CreateObject( "ADODB.Connection" )
con.Open "webLeads"
SQLstring = "INSERT INTO studentLeads ( la_fName, la_mName, la_lName,
la_street, " &_
" la_city, la_state, la_zip, la_country, la_email, la_phone, la_callTime,
la_dob, la_age, " &_
" la_education, la_intArea, la_message) VALUES ('" & fixQuotes( form_fName )
& "','" & fixQuotes( form_mName ) & "', " &_
" '" & fixQuotes( form_lName ) & "','" & fixQuotes( form_street ) & "','" &
fixQuotes( form_city ) & "', " &_
" '" & fixQuotes( form_stateID ) & "','" & fixQuotes( form_zip ) & "','" &
fixQuotes( form_country ) & "', " &_
" '" & fixQuotes( form_email ) & "','" & fixQuotes( form_phone ) & "','" &
fixQuotes( form_callTime ) & "', " &_
" '" & fixQuotes( form_dob ) & "','" & fixQuotes( form_age ) & "','" &
fixQuotes( form_education ) & "', " &_
" '" & fixQuotes( form_intArea ) & "','" & fixQuotes( form_message ) & " )"
con.Execute(SQLstring)
con.Close
I've also tried it w/ DSN-less connection, w/ same result. Variables are
assigned and validated as follows:
'get form data and remove any spaces
form_fName=trim(Request.Form("fName"))
form_mName=trim(Request.Form("mName"))
form_lName=trim(Request.Form("lName"))
form_street=trim(Request.Form("street"))
form_city=trim(Request.Form("city"))
form_stateID=trim(Request.Form("stateID"))
form_zip=trim(Request.Form("zip"))
form_country=trim(Request.Form("country"))
form_email=trim(Request.Form("email"))
form_phone=trim(Request.Form("phone"))
form_callTime=trim(Request.Form("callTime"))
form_dob=trim(Request.Form("dob"))
form_age=trim(Request.Form("age"))
form_education=trim(Request.Form("education"))
form_intArea=trim(Request.Form("intArea"))
form_message=trim(Request.Form("message"))
'validate form data
IF len(form_fname)< 1 THEN
validated_form = false
ELSE
validated_form = true
END IF
IF len(form_mname) < 1 THEN
validated_form = false
ELSE
validated_form = true
END IF
IF len(form_lname) < 2 THEN
validated_form = false
ELSE
validated_form = true
END IF
IF len(form_street) < 5 THEN
validated_form = false
ELSE
validated_form = true
END IF
IF len(form_city) < 2 THEN
validated_form = false
ELSE
validated_form = true
END IF
IF len(form_zip) < 5 THEN
validated_form = false
ELSE
validated_form = true
END IF
IF (form_country) = "" THEN
form_country = "U.S."
END IF
IF len(form_email) < 6 THEN
validated_form = false
ELSE
validated_form = true
END IF
IF len(form_phone) < 7 THEN
validated_form = false
ELSE
validated_form = true
END IF
IF (form_dob) = "" THEN
form_dob = "not given"
END IF
IF (form_age) = "" THEN
form_age = "not given"
END IF
IF (form_intArea)= "" THEN
validated_form = false
ELSE
validated_form = true
END IF
IF (form_message) = "" THEN
form_message = "no message indicated"
END IF
All form entries are defined as <input type="text"> and also as text fields
in the db. There is also a "fixquotes" function that takes care of the '
problem (have used this function over and over in many scripts.
I'm sure there's something simple I'm missing here, but maybe I've been
looking at it too long. The validation works for return values, and correctly
sends email to the user and to someone in the organization. Can anyone see
anything in my code that is causing the error and keeping the data out of the
db?
TIA...
ba