Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

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:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old February 17th, 2003, 11:55 PM
bella bella is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Sydney
Posts: 33 bella User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 21 m 46 sec
Reputation Power: 6
"Syntax error with insert into statement"

I am interacting with my database by way of asp and ado...unfortunately, it seems i have a problem with the following query - my browser reports an error "syntax error with insert into statement"....

any ideas on why this might be????? the database is Access


insertstr = "insert into Project(ProjectName, Department, Priority, Start_date, Est_end_date, IT_proj_mgr, Bus_mgr, Bus_owner) Values('" & proj_name & "', " & department & ", '" & priority & "', #" & begdate & "#, #" & findate & "#, " & IT_pm_id & ", " & bus_pm_id & ", " & bus_owner_id & ")"

Reply With Quote
  #2  
Old February 18th, 2003, 12:09 AM
a.koepke's Avatar
a.koepke a.koepke is offline
Second highest poster :p
Dev Shed God 5th Plane (7000 - 7499 posts)
 
Join Date: Jul 2001
Posts: 7,323 a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 8 h 8 m 45 sec
Reputation Power: 26
Quote:
" & department & "


Where are the quotes around this bit of data, is it text data or an int?

Reply With Quote
  #3  
Old February 18th, 2003, 03:59 PM
bella bella is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Sydney
Posts: 33 bella User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 21 m 46 sec
Reputation Power: 6
department is the id of a department, so it is an integer - no quotes required

Reply With Quote
  #4  
Old February 18th, 2003, 07:59 PM
a.koepke's Avatar
a.koepke a.koepke is offline
Second highest poster :p
Dev Shed God 5th Plane (7000 - 7499 posts)
 
Join Date: Jul 2001
Posts: 7,323 a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 8 h 8 m 45 sec
Reputation Power: 26
I really can't see the problem.

Try using debug.print insertstr before the execute statement and then post the sql statement. That way we can see what is getting passed with sample data in there. Makes it much easier to see any faults.

Reply With Quote
  #5  
Old February 19th, 2003, 02:47 AM
yassoor's Avatar
yassoor yassoor is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Canada - Egypt
Posts: 60 yassoor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
few things might be worth checking

bella,

I completely agree with a.koepke.
I haven't used the debug.print, just print the insertstr variable and don't really execute the query, so you would be able to see exactly what is being passed.

In sql staments a few things you might want to check on:

1. The table doesn't have any columns that can not be empty
and were not included in the insert statment.
__________________
I hope this is of any help to anyone.

Yassoor
http://www.WebsitesCreation.ca

Reply With Quote
  #6  
Old February 19th, 2003, 02:47 AM
yassoor's Avatar
yassoor yassoor is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Canada - Egypt
Posts: 60 yassoor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
few things might be worth checking

bella,

I completely agree with a.koepke.
I haven't used the debug.print, normally I just print the insertstr variable and don't really execute the query, so you would be able to see exactly what is being passed.

In sql staments a few things you might want to check on:

1. The table is not open for read only. create a dumy table and try inserting somthing into it just to make sure insertion in to the db from asp is possible.

2. The table doesn't have any columns that can not be empty "NOT Null" property in MySQL or "zero length allowed" in ACCESS
a. and were not included in the insert statment.
b. or the value passed was blank string.

3. The integer values retrieve from the FORM is not blank
eg.
Dim x = Request.(xFromForm)
insert into table( col1str. col2int. col3str ) values ( "v1", x, "v2)
This will generate:
insert into table( col1str. col2int. col3str ) values ( "v1", , "v2)
causing errors.

4. The date format is valid.

5. Stings passed in variables do not include '
if strx = "I'll get this done"
insert into (strvalue) Values (' " & x & " ')
will result in
insert into (strvalue) Values ('I'll get this done') which will cause error

Note: I think, and I have done it before, the date is passed as '2000/02/02' not like the way you have done it #2000/02/02#

Hope this was of any help

Last edited by yassoor : February 19th, 2003 at 02:59 AM.

Reply With Quote
  #7  
Old February 19th, 2003, 04:15 PM
bella bella is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Sydney
Posts: 33 bella User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 21 m 46 sec
Reputation Power: 6
turned out i had some problems with my client side scripts that weren't changing field values correctly...consequently some of the values being passed were blank which caused the dramas

thankyou for all your help anyway though!!!!

Reply With Quote
  #8  
Old February 20th, 2003, 02:20 AM
a.koepke's Avatar
a.koepke a.koepke is offline
Second highest poster :p
Dev Shed God 5th Plane (7000 - 7499 posts)
 
Join Date: Jul 2001
Posts: 7,323 a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level)a.koepke User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 8 h 8 m 45 sec
Reputation Power: 26
Awesome... remember when you have problems with SQL its always a good idea to print out the SQL so you can see what is going on. Easiest way to debug SQL.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > "Syntax error with 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 5 hosted by Hostway