Print Page | Close Window

What the hell?

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Database Discussion
Forum Description: Discussion and chat on database related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=7760
Printed Date: 28 March 2026 at 2:24am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: What the hell?
Posted By: adnan248999
Subject: What the hell?
Date Posted: 01 December 2003 at 8:11am

I am using an ms access database and trying to insert data into it using sql INSERT INTO and i get an error saying:

 "Syntax error in INSERT INTO statement."

What the hell is going on? I have check my data to make sure they are string values since the field types in my databse are ALL set to text.

This is my code:

<%

Set adocon = Server.CreateObject("ADODB.Connection")

adocon.Provider = "Microsoft.Jet.OLEDB.4.0"

adocon.open (server.mappath("mydb.mdb"))

Dim insertuser

insertuser = "INSERT INTO tblAuthor (Username, Realname, Password) VALUES('"&regusername&"','"&reguserrealname& "','"&reguserpass&"')"

adocon.execute(insertuser)

set adocon=nothing

response.redirect("default.asp")

%>



-------------
They call me Bruce Lee



Replies:
Posted By: Eftie
Date Posted: 01 December 2003 at 8:39am

I think there are ' too much at the end:

insertuser = "INSERT INTO tblAuthor (Username, Realname, Password) VALUES('"&regusername&"','"&reguserrealname& "','"&reguserpass&"')"

should be

insertuser = "INSERT INTO tblAuthor (Username, Realname, Password) VALUES('"&regusername&"','"&reguserrealname& "'," & reguserpass & ")"

 



-------------
Eftie


Posted By: adnan248999
Date Posted: 01 December 2003 at 9:10am
Originally posted by Eftie Eftie wrote:

I think there are ' too much at the end:

insertuser = "INSERT INTO tblAuthor (Username, Realname, Password) VALUES('"&regusername&"','"&reguserrealname& "','"&reguserpass&"')"

should be

insertuser = "INSERT INTO tblAuthor (Username, Realname, Password) VALUES('"&regusername&"','"&reguserrealname& "'," & reguserpass & ")"

 

 

Nope that didn't help one bit



-------------
They call me Bruce Lee


Posted By: Gullanian
Date Posted: 01 December 2003 at 10:07am

Correct syntax is:

INSERT INTO tblAuthor (Username, Realname, Password) VALUES('" & regusername & "','" & reguserrealname & "','" & reguserpass & "')

Gaps between the &'s are pretty important I think.  If it doesnt work make sure those 3 variables are holding values



Posted By: Eftie
Date Posted: 01 December 2003 at 10:24am

Found it:

username and password are protected variables, looks like it

Rename the names in tblAuthor to UUsername and UPassword and use:

Set adocon = Server.CreateObject("ADODB.Connection")
adocon.Provider = "Microsoft.Jet.OLEDB.4.0"
adocon.open (server.mappath("mydb.mdb"))

Dim insertuser

'Used for testing
regusername = "nickname"
reguserrealname = "realname"
reguserpass = "secret"

insertuser = "INSERT INTO tblAuthor (UUsername, Realname, UPassword) VALUES ('"&regusername&"','"&reguserrealname& "','"&reguserpass&"')"

response.write insertuser

adocon.execute(insertuser)

set adocon=nothing

'response.redirect("default.asp")

Edit: just tested this script on my localhost and this works.

Regards



-------------
Eftie


Posted By: adnan248999
Date Posted: 01 December 2003 at 11:36am

Hey thanx alot that helped the problems is now solved thanx to all that tried to help. One question though...Does anyone know where to get a list of reserved names that access uses so i know what not to name my fields in the database.

Thanx



-------------
They call me Bruce Lee


Posted By: Eftie
Date Posted: 01 December 2003 at 1:49pm

See topic:

http://forums.webwiz.net/forum_posts.asp?TID=6998&PN=1 - http://forums.webwiz.net/forum_posts.asp?TID=6998&a mp;PN=1  
reffering to
http://www.flws.com.au/showusyourcode/codeLib/code/odbc_keywords.asp - http://www.flws.com.au/showusyourcode/codeLib/code/odbc_keyw ords.asp

Makes everything more weird ;-)

Username and password are no reserved words.



-------------
Eftie


Posted By: pmormr
Date Posted: 01 December 2003 at 5:01pm

too many darn words



-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/


Posted By: ljamal
Date Posted: 01 December 2003 at 6:06pm
password is a reserved word with SQL Server, so it may also be in Access. If you want to use reserved words than you surround them with brackets []. This is not required with SQL Server 2000.

-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming


Posted By: adnan248999
Date Posted: 01 December 2003 at 7:03pm
cheers

-------------
They call me Bruce Lee


Posted By: zaboss
Date Posted: 02 December 2003 at 12:07am

To avoid al the problems that might occur, you'd better use a prefix in front of it: tblWhateverNameYouWant and fdWhateverNameYouWant.

This way is easyer to keep track of everything and also use reserved names like Name, From etc...



-------------
Cristian Banu
http://www.soft4web.ro - Soft 4 web



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net