Forum Moderators: open
sqlStatement = "INSERT INTO users (user_name, password, first_name, last_name, address1, address2, city, state, zip, phone, email, corp_name, corp_address, corp_city, corp_state, corp_zip, corp_phone, corp_email, mailings) VALUES ('" &user_name& "', '" &password& "', '" &first_name& "', '" &last_name& "', '" &address1& "', '" &address2& "', '" &city& "', '" &state& "', '" &zip& "', '" &phone& "', '" &email& "', '" &corp_name& "', '" &corp_address& "', '" &corp_city& "', '" &corp_state& "', '" &corp_zip& "', '" &corp_phone& "', '" &corp_email& "', '" &mailings& "')"
Set recordSet=cn.Execute(sqlStatement),1,2
cn.Close
Set cn=Nothing
Also for an INSERT statement like that you don't need to do "set recordset", the ,1,2 stuff, or waste memory creating a string called "sqlStatement".
just do this alone on a line:
cn.execute(YourInsertStatement)
See if that works - if you still get an error the problem is with a misplaced apostrophe or quotation mark.
Microsoft JET Database Engine error '80040e14'
Syntax error in INSERT INTO statement.
/register_action.asp, line 29
Line 29 is the whole statement. I am goign to keep looking. Just letting you know how that worked.
That might be your syntax error... maybe someone can correct me if I'm wrong or look it up though.
Set recordSet=cn.Execute(sqlStatement),1,2
Set recordSet=cn.Execute(sqlStatement,1,2)
As for the SQL you posted in msg#8, no, that isn't enough. You need to capture the entire SQL statement from "INSERT" through the closing ")" after the values. (what you did post looks okay)
Syntax error in FROM clause.
/register_action.asp, line 30
Yes the "yes" is that way by radio buttons...and it is a yes and no feild in the database.
Is this what you need?
user_name, password, first_name, last_name, address1, address2, city, state, zip, phone, email, corp_name, corp_address, corp_city, corp_state, corp_zip, corp_phone, corp_email, mailings, 'wweidner', 'mine', 'Wanda', 'Weidner', '', '', '', 'PA', '', '', 'wweidner@webstardesign.net', 'Web Star Design', '', '', 'PA', '', '', '', 'Yes'
Your most recent post said there was an error with a FROM clause, yet you have never posted any code with a FROM clause in it - how are we supposed to help you?
And again, there is no point in doing the Set Record thing on an insert statement. No data is being RETURNED to you so all you're doing is setting a null value. When doing an insert or update just use cn.execute(sqlstatement) and that's all you need. If you're selecting one value use:
stringname = cn.execute(sqlstatement)(0)
Only if you are running a SELECT statement where you're returning more than one value will you need to use the set recordset = stuff
If you want to see all of the code for the whole page go to .....www.tsi-certifications.com
Click on session info then schedule then register
That is the page that is not working right, the register_action.asp is the one that has all the code.
Here is all the code for the register_action.asp page. I have alot of it blocked off.
<%@ language="vbscript" %>
<%
if request.form("submit") = "" then
response.redirect "register.asp"
end if
%>
<!-- #include file="includes/connection.inc" -->
<%
first_name = request.form("first_name")
last_name = request.form("last_name")
user_name = left(first_name, 1) & last_name
user_name = lcase(user_name)
password = request.form("password")
address1 = request.form("address1")
address2 = request.form("address2")
city = request.form("city")
state = request.form("state")
zip = request.form("zip")
phone = request.form("phone")
email = request.form("email")
corp_name = request.form("corp_name")
corp_address = request.form("corp_address")
corp_city = request.form("corp_city")
corp_state = request.form("corp_state")
corp_zip = request.form("corp_zip")
corp_phone = request.form("corp_phone")
corp_email = request.form("corp_email")
mailings = request.form("mailings")
response.write "user_name, password, first_name, last_name, address1, address2, city, state, zip, phone, email, corp_name, corp_address, corp_city, corp_state, corp_zip, corp_phone, corp_email, mailings, '" &user_name& "', '" &password& "', '" &first_name& "', '" &last_name& "', '" &address1& "', '" &address2& "', '" &city& "', '" &state& "', '" &zip& "', '" &phone& "', '" &email& "', '" &corp_name& "', '" &corp_address& "', '" &corp_city& "', '" &corp_state& "', '" &corp_zip& "', '" &corp_phone& "', '" &corp_email& "', '" &mailings& "'"
'sqlStatement = "INSERT INTO users (user_name, password, first_name, last_name, address1, address2, city, state, zip, phone, email, corp_name, corp_address, corp_city, corp_state, corp_zip, corp_phone, corp_email, mailings) VALUES ('" &user_name& "', '" &password& "', '" &first_name& "', '" &last_name& "', '" &address1& "', '" &address2& "', '" &city& "', '" &state& "', '" &zip& "', '" &phone& "', '" &email& "', '" &corp_name& "', '" &corp_address& "', '" &corp_city& "', '" &corp_state& "', '" &corp_zip& "', '" &corp_phone& "', '" &corp_email& "', '" &mailings& "')"
'Set recordSet=cn.Execute(sqlStatement,1,2)
'cn.Close
'Set cn=Nothing
'set fso = Server.CreateObject("Scripting.FileSystemObject")
'set countFile = fso.OpenTextFile(Server.MapPath("count.txt"))
'if not countFile.AtEndOfStream then
'full = countFile.Readline
' session("full") = full
' visitor = full mod 12
' if visitor = 0 then
' session("discount") = "true"
' else
' session("discount") = "false"
' end if
'end if
'countFile.close
'set fso = Server.CreateObject("Scripting.FileSystemObject")
'set countFile = fso.CreateTextFile(Server.MapPath("count.txt"))
'countFile.WriteLine full+1
'countFile.Close
'connection.Close
'set connection=Nothing
'session("user_name") = user_name
'session("password") = password
'session("name") = first_name & " " & last_name
'message_body = "Thank you for registering with TSI Certifications. Your user name is " & 'user_name & " and your password is " & password & "."
'Set NewMail = Server.CreateObject("CDONTS.NewMail")
'NewMail.To = "wweidner@webstardesign.net (TSI Certification)"
'NewMail.From = request.form("email") & " (" & request.form("name") & ")"
'NewMail.Cc = request.form("email") & " (" & request.form("name") & ")"
'NewMail.Subject = "Mail from the TSI-Certifications user login details"
'NewMail.Body = Body
'NewMail.Send
'Set NewMail=Nothing
'response.redirect "session.asp"
%>
Response.Write sqlStatement
Response.End
What digitalv is getting at is that we need to see the entire SQL statement that is being executed as the error lies somewhere in there.
response.write "user_name, password, first_name, last_name, address1, address2, city, state, zip, phone, email, corp_name, corp_address, corp_city, corp_state, corp_zip, corp_phone, corp_email, mailings, '" &user_name& "', '" &password& "', '" &first_name& "', '" &last_name& "', '" &address1& "', '" &address2& "', '" &city& "', '" &state& "', '" &zip& "', '" &phone& "', '" &email& "', '" &corp_name& "', '" &corp_address& "', '" &corp_city& "', '" &corp_state& "', '" &corp_zip& "', '" &corp_phone& "', '" &corp_email& "', '" &mailings& "'"'sqlStatement = "INSERT INTO users (user_name, password, first_name, last_name, address1, address2, city, state, zip, phone, email, corp_name, corp_address, corp_city, corp_state, corp_zip, corp_phone, corp_email, mailings) VALUES ('" &user_name& "', '" &password& "', '" &first_name& "', '" &last_name& "', '" &address1& "', '" &address2& "', '" &city& "', '" &state& "', '" &zip& "', '" &phone& "', '" &email& "', '" &corp_name& "', '" &corp_address& "', '" &corp_city& "', '" &corp_state& "', '" &corp_zip& "', '" &corp_phone& "', '" &corp_email& "', '" &mailings& "')"
'Set recordSet=cn.Execute(sqlStatement,1,2)
With this:
sqlStatement = "INSERT INTO users (user_name,password,first_name,last_name,address1,address2,city,state,zip,phone,email,corp_name,corp_address,corp_city,corp_state,corp_zip,corp_phone,corp_email,mailings) VALUES ('" & user_name & "','" & password & "','" & first_name & "','" & last_name & "','" & address1 & "','" & address2 & "','" & city & "','" & state & "','" & zip & "','" & phone & "','" & email & "','" & corp_name & "','" & corp_address & "','" & corp_city & "','" & corp_state & "','" & corp_zip & "','" & corp_phone & "','" & corp_email & "','" & mailings & "')"
response.write sqlStatement
cn.Execute(sqlStatement)
If this produces a syntax error it's because one of the fields is wrong. Start by taking away the fields from the back, one at a time, until you find the problem. Take out mailings first, then corp_email, etc. I suspect the problem is with mailings, but not sure - make sure you take it out of the column names AND the values.
INSERT INTO users (user_name, password, first_name, last_name, address1, address2, city, state, zip, phone, email, corp_name, corp_address, corp_city, corp_state, corp_zip, corp_phone, corp_email, mailings) VALUES ('wweidner', 'mine', 'Wanda', 'Weidner', '', '', '', 'PA', '', '', 'wweidner@webstardesign.net', 'Web Star Design', '', '', 'PA', '', '', '', 'Yes')
Is this it?
Also, before replying, try to execute that statement directly in Access if you can. You may get a more meaningful error message.
And lastly, the syntax of whay you posted looks okay. So I would take a closer look at the 'yes' going into the yes/no field. If you write a 1 (for yes) or 0 (for no). Try putting in a litteral value of 1 (without the apostrophes) instead of the 'yes' to see if that makes the error go away.
Microsoft JET Database Engine error '80040e14'
Syntax error in INSERT INTO statement.
/register_action.asp, line 33
and line 33 is
cn.Execute(sqlStatement)
This is after i have been taking things out and rerunning it. I guess i am not going to get it to work. I don't know what else to try and or do. but i thank you for all the help
first_name = request.form("first_name")
last_name = request.form("last_name")
address1 = request.form("address1")
address2 = request.form("address2")
city = request.form("city")
state = request.form("state")
zip = request.form("zip")
phone = request.form("phone")
corp_name = request.form("corp_name")
corp_address = request.form("corp_address")
corp_city = request.form("corp_city")
corp_state = request.form("corp_state")
corp_zip = request.form("corp_zip")
corp_phone = request.form("corp_phone")
sqlStatement = "INSERT INTO users ( first_name, last_name, address1, address2, city, state, zip, phone, corp_name, corp_address, corp_city, corp_state, corp_zip, corp_phone, ) VALUES ('" &first_name& "', '" &last_name& "', '" &address1& "', '" &address2& "', '" &city& "', '" &state& "', '" &zip& "', '" &phone& "', '" &corp_name& "', '" &corp_address& "', '" &corp_city& "', '" &corp_state& "', '" &corp_zip& "', '" &corp_phone& "')"
cn.Execute(sqlStatement)---> line 32 (right now)
Is the problem
On Error Resume Next
cn.Execute(sqlStatement)
If cn.Errors.Count > 0 Then
If cn.Errors.Item(0).Number <> 0 Then
Response.write "Error: " & cn.Errors.Item(0).Description
cn.close
Response.End
End If
End If
sqlStatement = "INSERT INTO users ( first_name, last_name, address1, address2, city, state, zip, phone, corp_name, corp_address, corp_city, corp_state, corp_zip, corp_phone, ) VALUES ('" &first_name& "', '" &last_name& "', '" &address1& "', '" &address2& "', '" &city& "', '" &state& "', '" &zip& "', '" &phone& "', '" &corp_name& "', '" &corp_address& "', '" &corp_city& "', '" &corp_state& "', '" &corp_zip& "', '" &corp_phone& "')"
You have a comma after the field name corp_phone, and that is a syntax error.
Again, try and execute these directly in Access, or loop through the connection errors as suggested by duckhunter - you will (usually) get a more meaningful error message.
first_name = request.form("first_name")
last_name = request.form("last_name")
-->user_name = left(first_name, 1) & last_name
-->user_name = lcase(user_name)
password = request.form("password")
address1 = request.form("address1")
address2 = request.form("address2")
city = request.form("city")
state = request.form("state")
zip = request.form("zip")
phone = request.form("phone")
email = request.form("email")
corp_name = request.form("corp_name")
corp_address = request.form("corp_address")
corp_city = request.form("corp_city")
corp_state = request.form("corp_state")
corp_zip = request.form("corp_zip")
corp_phone = request.form("corp_phone")
corp_email = request.form("corp_email")
sqlStatement = "INSERT INTO users (-->user_name, password--<, first_name, last_name, address1, address2, city, state, zip, phone, email, corp_name, corp_address, corp_city, corp_state, corp_zip, corp_phone,corp_email) VALUES (-->'" &user_name& "', '" &password& "'--<,'" &first_name& "', '" &last_name& "', '" &address1& "', '" &address2& "', '" &city& "', '" &state& "', '" &zip& "','" &phone& "','" &email& "', '" &corp_name& "', '" &corp_address& "', '" &corp_city& "', '" &corp_state& "', '" &corp_zip& "', '" &corp_phone& "', '" &corp_email& "')"
I am getting a syntax error...
Error: Syntax error in INSERT INTO statement.
Any ideas why.
Just a heads up, you can simplify this into one line by doing:
user_name = lcase(Left(first_name,1) & last_name)
Also if the username is ALWAYS going to be first initial/last name then you can save some space in the database and skip that field entirely. If the first and last name are stored in the DB you can dynamically build the username from that when someone logs in:
Username = request.form("username")
SELECT whatever FROM Users WHERE Left(first_name,1) = '" & Left(Username,1) & "' AND Last_name = '" & Right(Username,len(Username) - 1)) & "'"
Still not sure about the error, you blocked out the password field - was the problem with the Username or with the password or both?
The error is occurring because of something in that statement. You aren't posting it with your questions. Each time you change something, if you have another question to post, you should post
- The error message (or the problem if there is no message)
- The vbscript from the line on which the error occurs at least (surrounding code is always nice)
- If the error was in executing the SQL, then run your code again with the Response.Write and Response.End BEFORE the .Execute statement and include that actual SQL in your post.
I think that last bit is being lost on you. We need to see the VbScript that creates the SQL >>AND<< we need to see the actual SQL.
Having said all of that, I would guess that one of those two fields is an empty string.
Also, are you unable to run the actual SQL in Access?
INSERT INTO users (user_name, password, first_name, last_name, address1, address2, city, state, zip, phone, email, corp_name, corp_address, corp_city, corp_state, corp_zip, corp_phone, corp_email) VALUES ('fweidner', 'mine','Fred', 'Weidner', '3456 My Street', 'suite 345', 'mine', 'PA', '26475','610-675-3567','wild_ones_2004@yahoo.com', 'Web Star Design', '3456 My Street', 'mine', 'PA', '26475', '610-675-3567', 'wweidner@webstardesign.net')Error: Syntax error in INSERT INTO statement.
here is the all of the code ( --> and --< is what i have added back in and then got the syntax error)
first_name = request.form("first_name")
last_name = request.form("last_name")
-->user_name = lcase(Left(first_name,1) & last_name)
-->password = request.form("password")
address1 = request.form("address1")
address2 = request.form("address2")
city = request.form("city")
state = request.form("state")
zip = request.form("zip")
phone = request.form("phone")
email = request.form("email")
corp_name = request.form("corp_name")
corp_address = request.form("corp_address")
corp_city = request.form("corp_city")
corp_state = request.form("corp_state")
corp_zip = request.form("corp_zip")
corp_phone = request.form("corp_phone")
corp_email = request.form("corp_email")
sqlStatement = "INSERT INTO users (-->user_name, password--<, first_name, last_name, address1, address2, city, state, zip, phone, email, corp_name, corp_address, corp_city, corp_state, corp_zip, corp_phone,corp_email) VALUES (-->'" &user_name& "', '" &password& "'--<,'" &first_name& "', '" &last_name& "', '" &address1& "', '" &address2& "', '" &city& "', '" &state& "', '" &zip& "','" &phone& "','" &email& "', '" &corp_name& "', '" &corp_address& "', '" &corp_city& "', '" &corp_state& "', '" &corp_zip& "', '" &corp_phone& "', '" &corp_email& "')"
On Error Resume Next
response.write sqlStatement
cn.Execute(sqlStatement)
If cn.Errors.Count > 0 Then
If cn.Errors.Item(0).Number <> 0 Then
Response.write "Error: " & cn.Errors.Item(0).Description
cn.close
Response.End
End If
End If
cn.Close
Set cn=Nothing