SunQuest
           ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old July 7th, 2003, 02:21 PM
kb2tfa kb2tfa is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 5 kb2tfa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to kb2tfa Send a message via AIM to kb2tfa Send a message via Yahoo to kb2tfa
Post Syntax error in INSERT INTO statement.

I have been messing with this code for a while now, and I need a fresh set of eyes to look at it. My DB table is set up with the exact number of colums, and in the insert order. I can insert username and username's value with everything else commented out, but as soon as I add the next field (password) it goes nutty.... below is the page of code followed by the output on the screen.

--------TAKE_REGISTRATION.ASP---------------------
p_userid = Request.QueryString("p_name")
p_pass1 = Request.QueryString("p_pass1")
p_pass2 = Request.QueryString("p_pass2")
p_first = Request.QueryString("p_first")
p_last = Request.QueryString("p_last")
p_email = Request.QueryString("p_email")

'create the object
set guilmetrpDB = Server.CreateObject ("ADODB.Connection")
'open the connection
guilmetrpDB.Open strconn


'insert record here
'theSQL = "insert into members values('rxguil3', 'pass2', 'ron', 'guil', 'me.com')"
theSQL = "insert into members "
theSQL = theSQL & "(username, password, first_name, last_name, email)"
theSQL = theSQL & " values ('"&p_userid&"','"&p_pass1&"', '"&p_first&"', '"&p_last&"', '"&p_email&"')"

' print to debug
Response.Write theSQL

guilmetrpDB.Execute theSQL

'close connection
guilmetrpDB.Close
'destroy the connection
set guilmetrpDB = Nothing

---------SCREEN SHOT----------------

insert into members (username, password, first_name, last_name, email) values ('rxguil','imouturn', 'ron', 'guilmet', 'me@me.com')
Microsoft JET Database Engine error '80040e14'

Syntax error in INSERT INTO statement.

/take_registration.asp, line 27

-----------------------------------------------

any help would be nice, for my eyes are bleeding.

Reply With Quote
  #2  
Old July 7th, 2003, 07:20 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,716 Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 1 Month 33 m 54 sec
Reputation Power: 688
I think password is a reserved word. Try putting [ ] around it in your sql

theSQL = theSQL & "(username, [password], first_name, last_name, email)"

Reply With Quote
  #3  
Old July 7th, 2003, 07:27 PM
victorpendleton victorpendleton is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2003
Location: No es importante
Posts: 2,065 victorpendleton User rank is Private First Class (20 - 50 Reputation Level)victorpendleton User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 6 h 31 m 56 sec
Reputation Power: 8
Have you tried removing password and just using the other four paramenters?
Also, you may want to print out the values of each parameter to ensur they are what you think they are.

Reply With Quote
  #4  
Old July 10th, 2003, 11:17 AM
AAndersen AAndersen is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 6 AAndersen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I could be way off but try it like this:

theSQL = "INSERT INTO members (username, password, first_name, last_name, email) VALUES ('" & p_userid & "', '" & p_pass1 & "', '" & p_first & "', '" & p_last & "', '" & p_email & "')"

and then like victorpendleton was saying do a response.write(theSQL) to see if your output is what you expect

I also noticed that in your error message all the values have space after the comma except for the the first two, maybe this has something to do with the error.

Reply With Quote
  #5  
Old July 10th, 2003, 06:06 PM
AAndersen AAndersen is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 6 AAndersen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Nevermind the [password] thing is definantly the reason, is just tried recreating a database and script that was very similar and I got an invalid syntax error then I put password in [] and the it wrote to the table just fine.

So that makes me wonder, if password is a reserved word, what is it reserved for

Reply With Quote
  #6  
Old July 11th, 2003, 08:33 AM
lordkyl lordkyl is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 27 lordkyl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally posted by AAndersen
Nevermind the [password] thing is definantly the reason, is just tried recreating a database and script that was very similar and I got an invalid syntax error then I put password in [] and the it wrote to the table just fine.

So that makes me wonder, if password is a reserved word, what is it reserved for



I think there is an Access datatype called "password"

Reply With Quote
  #7  
Old July 11th, 2003, 09:36 AM
kb2tfa kb2tfa is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 5 kb2tfa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to kb2tfa Send a message via AIM to kb2tfa Send a message via Yahoo to kb2tfa
In my post I included the original code, and the "screen shot" code which shows that I print out also the sql statement to ensure my data is correct.
I also looked up if "Password" is a reserved word, and according to the documentation "Password" is not.
However, I did change the Request.Querystring to Requset("p_name"), and it works now. The only thing I can think of is that maybe something dirty was in the querystring coming from the form, but I as you can see from the sql output (stated in the first post) there is no descrepency.

Well the problem, what ever it was, seems to be fixed. Thanks again looking at the code...
Ron

Reply With Quote
  #8  
Old July 11th, 2003, 10:33 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,716 Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 1 Month 33 m 54 sec
Reputation Power: 688
I don't see password in any list of reserved words for Access either, but I've had the same problem in the past and using the MS [ ] syntax fixed the problem for me too.

Reply With Quote
  #9  
Old July 14th, 2003, 12:09 PM
AAndersen AAndersen is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 6 AAndersen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Well you know, that is why we all love Access so much

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Syntax error in INSERT INTO statement.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway