Jump to content

should be simple: adding to a DB problem


wilsonf1

Recommended Posts

hi i want to use a form for people to submit their email addresses from my site - id also like the date of the submission redorded tooi can get it working when there is just one column named 'email' (and ofcourse id for key) and the address adds fine, when i try to add a second value it doesnthere is my working lines (with a database that just has email column):insertSQL = "INSERT INTO emails (email) VALUES ('" & emailadd & "'')"'response.Write(insertSQL)databaseConnection.Execute insertSQL, adLockPessimisticthis doesnt work (extra date column added) - with the errors being:Syntax error in INSERT INTO statement. ln 28.26 insertSQL = "INSERT INTO emails (email,date) VALUES ('" & emailadd & "','10')"27 'response.Write(insertSQL)28 databaseConnection.Execute insertSQL, adLockPessimisticive tried fiddling with that second value, im using 10 just as a simple example before trying to add the date variable, with quotes, without quotes, it just complains?????????

Link to comment
Share on other sites

this may help, i unleashed the response.write - whats up with this!!:INSERT INTO emails (email,date) VALUES ('admin@enterf2.co.uk','13/03/2007')Microsoft JET Database Engine error '80040e14'Syntax error in INSERT INTO statement./mclaren-teamcasts-email2.asp, line 28

Link to comment
Share on other sites

It must be some "reserved keywords" problem.... in that case you need to use such words within square brackets []. try this.... guessing reserved word must be "date" so, your query should be like this....INSERT INTO emails (email,[date]) VALUES ('admin@enterf2.co.uk','13/03/2007')code:insertSQL = "INSERT INTO emails (email,[date]) VALUES ('" & emailadd & "','10')"

Link to comment
Share on other sites

i tried the square brackets and a new column name, the result:INSERT INTO emails (email,date_added) VALUES ('admin@enterf2.co.uk','13/03/2007')Microsoft JET Database Engine error '80040e07'Data type mismatch in criteria expression./mclaren-teamcasts-email2.asp, line 28

Link to comment
Share on other sites

Data type mismatch in criteria expression.
Maybe it's the way you are passing the date. Many database management systems store dates in the YYYY/MM/dd format. Try this query:
INSERT INTO emails (email,[date]) VALUES ('admin@enterf2.co.uk','2007/03/13')

EDIT: Also try "2007-03-13".

Link to comment
Share on other sites

Check you datatype of the "date_added" field, cos if its type is "date" then if you give string or number then it will give an error, also what database are you using? as jesh mentioned the date format might be different [eg: US format - mm/dd/yyyy]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...