Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - What the hell?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

What the hell?

 Post Reply Post Reply Page  12>
Author
adnan248999 View Drop Down
Newbie
Newbie
Avatar

Joined: 30 November 2003
Location: United Kingdom
Status: Offline
Points: 26
Post Options Post Options   Thanks (0) Thanks(0)   Quote adnan248999 Quote  Post ReplyReply Direct Link To This Post Topic: What the hell?
    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")

%>

Back to Top
Eftie View Drop Down
Groupie
Groupie


Joined: 17 March 2003
Location: Netherlands
Status: Offline
Points: 140
Post Options Post Options   Thanks (0) Thanks(0)   Quote Eftie Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
adnan248999 View Drop Down
Newbie
Newbie
Avatar

Joined: 30 November 2003
Location: United Kingdom
Status: Offline
Points: 26
Post Options Post Options   Thanks (0) Thanks(0)   Quote adnan248999 Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
Eftie View Drop Down
Groupie
Groupie


Joined: 17 March 2003
Location: Netherlands
Status: Offline
Points: 140
Post Options Post Options   Thanks (0) Thanks(0)   Quote Eftie Quote  Post ReplyReply Direct Link To This Post 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



Edited by Eftie
Eftie
Back to Top
adnan248999 View Drop Down
Newbie
Newbie
Avatar

Joined: 30 November 2003
Location: United Kingdom
Status: Offline
Points: 26
Post Options Post Options   Thanks (0) Thanks(0)   Quote adnan248999 Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
Eftie View Drop Down
Groupie
Groupie


Joined: 17 March 2003
Location: Netherlands
Status: Offline
Points: 140
Post Options Post Options   Thanks (0) Thanks(0)   Quote Eftie Quote  Post ReplyReply Direct Link To This Post Posted: 01 December 2003 at 1:49pm

See topic:

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

Makes everything more weird ;-)

Username and password are no reserved words.

Eftie
Back to Top
pmormr View Drop Down
Senior Member
Senior Member


Joined: 06 January 2003
Location: United States
Status: Offline
Points: 1479
Post Options Post Options   Thanks (0) Thanks(0)   Quote pmormr Quote  Post ReplyReply Direct Link To This Post Posted: 01 December 2003 at 5:01pm

too many darn words

Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.