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:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old July 12th, 2003, 04:47 PM
Tewl's Avatar
Tewl Tewl is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 47 Tewl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 57 m 13 sec
Reputation Power: 6
Insert Syntax Error

I'm getting Syntax error in INSERT INTO statement. for this code

Code:
        Dim sNow
        sNow = #1/12/2003 12:00 PM#
        sQuery = "insert into members (stime, name, password, email, level) values " _
                      & "(" & sNow & ", '" & sName & "', '" & sPasswd & "', '" & sEmail & "', 0)"


stime is datetime
name is varchar
passwd is varchar
email is varchar
an level is int

I'm using the 3.51 jet provider

I've tried this many different ways an I'm not getting anywhere does anyone see my error?
__________________
Tewl

Last edited by Tewl : July 13th, 2003 at 10:47 AM.

Reply With Quote
  #2  
Old July 12th, 2003, 07:04 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,703 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: 4 Weeks 1 Day 21 h 25 m 29 sec
Reputation Power: 688
With Access databases, you need to use # as a delimiter around dates, not '

Reply With Quote
  #3  
Old July 12th, 2003, 10:08 PM
Tewl's Avatar
Tewl Tewl is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 47 Tewl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 57 m 13 sec
Reputation Power: 6
I kno that. I have even tried this

Code:
  insert into members (name, password, email, level) values ('Nickname', 'password', 'auser@hotmail.com', 0)


An I'm still getting a insert error

Last edited by Tewl : July 12th, 2003 at 10:37 PM.

Reply With Quote
  #4  
Old July 13th, 2003, 02:12 AM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,703 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: 4 Weeks 1 Day 21 h 25 m 29 sec
Reputation Power: 688
Password is a reserved word. Try
Code:
insert into members (name, [password], email, level) values ('Nickname', 'password', 'auser@hotmail.com', 0)

Reply With Quote
  #5  
Old July 13th, 2003, 10:04 AM
Tewl's Avatar
Tewl Tewl is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 47 Tewl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 57 m 13 sec
Reputation Power: 6
No luck with that either. I even renamed the field to passwd an name to uname and still get the syntax error

Here is what I have at the moment

Code:
    Public Function AddMember(sName, sPasswd, sEmail)
      On Error Resume Next
      Dim sAddMember, sQuery
      sAddMember = "MemberAdded"
      adoCon.ConnectionString = dbProvider
      adoCon.Open
      ' check if user already exists
      sQuery = "select Count(*) from members where members.uname='" & sName & "'"
      adoRS.Open sQuery, adoCon, adOpenKeySet, adLockOptimistic
      If adoRS(0) <> 0 Then
        sAddMember = "MemberAlreadyExists"
      End If
      adoRS.Close
      ' check if email already exists
      sQuery = "select Count(*) from members where members.email='" & sEmail & "'"
      adoRS.Open sQuery, adoCon, adOpenKeySet, adLockOptimistic
      If adoRS(0) <> 0 Then
        sAddMember = "EmailAlreadyExists"
      End If
      adoRS.Close
      If sAddMember = "MemberAdded" Then
        sQuery = "insert into members (uname, passwd, email, level) values ('" & sName & "', '" & sPasswd & "', '" & sEmail & "', 0)"
        adoRS.Open sQuery, adoCon, adOpenKeySet, adLockOptimistic
      End If
      If Err.Number <> 0 Then
         response.write "Error occured while adding user to database.<br>Error #" & Err.Number & "<br>Description: " & Err.Description & "<br>"
      End If
      adoCon.Close
      AddMember = sAddMember
    End Function

Last edited by Tewl : July 13th, 2003 at 10:50 AM.

Reply With Quote
  #6  
Old July 13th, 2003, 02:19 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,703 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: 4 Weeks 1 Day 21 h 25 m 29 sec
Reputation Power: 688
Try taking out the on error resume next, maybe you're getting some error higher up in your code that's being hidden.

Reply With Quote
  #7  
Old July 13th, 2003, 02:33 PM
Tewl's Avatar
Tewl Tewl is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 47 Tewl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 57 m 13 sec
Reputation Power: 6
I've tried that too. I can run it without the insert an it works fine but when I try the insert it gives me an error

Reply With Quote
  #8  
Old July 13th, 2003, 10:50 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,703 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: 4 Weeks 1 Day 21 h 25 m 29 sec
Reputation Power: 688
Maybe there is something you need to do if you use a recordset to perform an insert statement. Typically if you have an open recordset you'll use .addnew

I usually do a con.execute "INSERT INTO table (col1) VALUES ('val1')" to do an insert instead of passing the sql to a recordset.

You could put a response.write sQuery just above the actual execution point and see just what the sql string looks like. Post it here if you have questions.

Reply With Quote
  #9  
Old July 15th, 2003, 04:17 AM
rgdubey rgdubey is offline
I am here to share knowledge
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: India
Posts: 83 rgdubey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
try this
store the value of level into a variable and then try to store that variable into the table maybe it is not storing the value 0 directly
it's a wild guess but try it
__________________
Rahul

Small things lead to perfection and perfection is not a small thing.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Insert Syntax Error


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 3 hosted by Hostway