SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseSQL Development

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 ASP Free Forums Sponsor:
  #1  
Old January 29th, 2000, 10:28 PM
Steve Schofield Steve Schofield is offline
Contributing User
ASP Free God 20th Plane (14500 - 14999 posts)
 
Join Date: Dec 2002
Posts: 14,575 Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 23
SQL INSERT and Numbers

<i><b>Originally posted by : Mike Horton (mhorton@planet.eon.net)</b></i><br /><br />I'm using a form to get information to insert into a database. I know from using Response.Write that the information passed is correct but I keep getting the following error: Syntax error in INSERT INTO statement.<br /><br />Here's my INSERT code:<br />SQLstmt = "INSERT INTO Drivers (First Name,Last Name,Country,Helmet)"<br />SQLstmt = SQLstmt & " VALUES (" <br />SQLstmt = SQLstmt & "'" & First_Name & "',"<br />SQLstmt = SQLstmt & "'" & Last_Name & "',"<br />SQLstmt = SQLstmt & "'" & Country & "',"<br />SQLstmt = SQLstmt & "'" & Helmet & "'"<br />SQLstmt = SQLstmt & ")"<br /><br />Now Country and Helmet are numbers (I've got them tied into relationships). I've used this exact same code when all the fields were text and it worked great. I've also seen where you use a # around a date so I've tried that with now success. Any help would be greatly appreciatted. BTW there's also a Yes/No field in the table. Does that have to be filled on the INSERT statement?<br /><br />Thanks

Reply With Quote
  #2  
Old February 15th, 2000, 05:50 PM
Steve Schofield Steve Schofield is offline
Contributing User
ASP Free God 20th Plane (14500 - 14999 posts)
 
Join Date: Dec 2002
Posts: 14,575 Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level)Steve Schofield User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 23
<i><b>Originally posted by : Devendra Tiwari (smriti786@netzero.net)</b></i><br />To get around this problem try this...<br />Call function to convert string data type to<br />a appropriate number datatype (like integer,long,double or currency).<br />ex :<br />01. ccur for currency <br />var xyz<br />xyz = ccur("123.456")<br />02. cdbl for double<br />03. cdate for date<br />04. cint for integer.<br />05. clng for long.<br /><br />I hope this helps.<br /><br />Thanks,<br />Devendra.<br /><br />------------<br />Mike Horton at 1/29/2000 7:28:32 PM<br /><br /><br />I'm using a form to get information to insert into a database. I know from using Response.Write that the information passed is correct but I keep getting the following error: Syntax error in INSERT INTO statement.<br /><br />Here's my INSERT code:<br />SQLstmt = "INSERT INTO Drivers (First Name,Last Name,Country,Helmet)"<br />SQLstmt = SQLstmt & " VALUES (" <br />SQLstmt = SQLstmt & "'" & First_Name & "',"<br />SQLstmt = SQLstmt & "'" & Last_Name & "',"<br />SQLstmt = SQLstmt & "'" & Country & "',"<br />SQLstmt = SQLstmt & "'" & Helmet & "'"<br />SQLstmt = SQLstmt & ")"<br /><br />Now Country and Helmet are numbers (I've got them tied into relationships). I've used this exact same code when all the fields were text and it worked great. I've also seen where you use a # around a date so I've tried that with now success. Any help would be greatly appreciatted. BTW there's also a Yes/No field in the table. Does that have to be filled on the INSERT statement?<br /><br />Thanks

Reply With Quote
  #3  
Old January 3rd, 2005, 11:47 AM
WebGuyX WebGuyX is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 2 WebGuyX User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 47 sec
Reputation Power: 0
I know this is probably never going to help the original person, but google rated this article to my first page of results when I was looking for a similar answer.

*Quote*
Syntax error in INSERT INTO statement.<br /><br />Here's my INSERT code:<br />SQLstmt = "INSERT INTO Drivers (First Name,Last Name,Country,Helmet)"<br />SQLstmt = SQLstmt & " VALUES (" <br />SQLstmt = SQLstmt & "'" & First_Name & "',"<br />SQLstmt = SQLstmt & "'" & Last_Name & "',"<br />SQLstmt = SQLstmt & "'" & Country & "',"<br />SQLstmt = SQLstmt & "'" & Helmet & "'"<br />SQLstmt = SQLstmt & ")"<br /><br />Now Country and Helmet are numbers (I've got them tied into relationships). I've used this exact same code when all the fields were text and it worked great. I've also seen where you use a # around a date so I've tried that with now success. Any help would be greatly appreciatted. BTW there's also a Yes/No field in the table. Does that have to be filled on the INSERT statement?<br /><br />Thanks
*End Quote*

The SQL above looks like this:
INSERT INTO Drivers (First Name,Last Name,Country,Helmet)" VALUES ('" & First_Name & "','" & Last_Name & "','" & Country & "'," & Helmet & "')

The appropriate SQL should read as follows note the missing appostrophes and added brackets:
INSERT INTO Drivers (First Name,Last Name,[Country],[Helmet])" VALUES ('" & First_Name & "','" & Last_Name & "'," & Country & "," & Helmet & ")

This has been tested and worked correctly using MS Access Databases.

Reply With Quote
  #4  
Old January 6th, 2005, 09:12 AM
Dumbo Dumbo is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 29 Dumbo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 27 m 31 sec
Reputation Power: 0
I'm sure you mean this

The appropriate SQL should read as follows note the missing appostrophes and added brackets:
INSERT INTO Drivers ([First Name],[Last Name],[Country],[Helmet])" VALUES ('" & First_Name & "','" & Last_Name & "'," & Country & "," & Helmet & ")

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseSQL Development > SQL INSERT and Numbers


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



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

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





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT