SQL INSERT INTO and Numbers - preCharge Forums
It shows that you are unregistered. Please register with us by clicking Here
preCharge Forums


Nav Green LeftNav Right
preCharge Forums > Website Design & Development > Programming > ASP » SQL INSERT INTO and Numbers


Reply
Tcat Right
 
LinkBack Thread Tools Display Modes Tcat Right
Old 07-08-2006   #1 (permalink)
ashley
Junior Member
 
Join Date: Jul 2006
Age: 48
Posts: 7
Default SQL INSERT INTO and Numbers

<i><b>Originally posted by : Mike Horton (mhorton@planet.eon.net)</b></i><br />I posted this question last night and it looks like I did it a day too soon <G> so here goes again.<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.<br />BTW There's also a Yes/No field in the table. Does that have to be filled and will a simple ' No ' do the trick?<br /><br />
Thanks
Ashley
ashley is offline   Reply With Quote


Old 07-10-2006   #2 (permalink)
Minakshi
Junior Member
 
Join Date: Jul 2006
Age: 39
Posts: 8
Default

Hi,
Pls make sure that you remove quotes (') before and after the numeric field. I think you are having problem because the numeric fields contain quotes. Also if the yes/No field is mandatory then only you need to includ them in the SQL query else you can leave it.
Minakshi is offline   Reply With Quote

Old 07-13-2006   #3 (permalink)
Tom Tom
Junior Member
 
Join Date: Jul 2006
Age: 48
Posts: 25
Default

The basic syntax for INSERT is

INSERT INTO <table name>
[(column name1, column name2,..)
VALUES
(Value1, Value2,...)]
<SELECT statement>

Looking at your statement it seams to be ok but I thing the numerical values shoud not have (') i think you need them for text only, try removing them from any numerical values and try again
Tom Tom is offline   Reply With Quote

Old 07-14-2006   #4 (permalink)
imehesz
Senior Member
 
imehesz's Avatar
 
Join Date: Jul 2006
Age: 30
Posts: 258
Default

here you can find the basic syntax for insert (in MySQL):

http://dev.mysql.com/doc/refman/5.0/en/insert.html
__________________
--
iM
imehesz is offline   Reply With Quote

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding numbers sebastian JavaScript 3 10-12-2006 03:02 AM
Insert lines to the beginning of a file logan Perl 0 07-27-2006 06:04 PM
American Express Numbers claire General Business Issues 1 07-12-2006 05:00 AM
Insert and update the same time alejandro ASP 1 07-06-2006 01:13 PM
Adding numbers miguel ASP 0 07-02-2006 08:08 AM


footer left
All times are GMT. The time now is 05:03 AM.

DISCLAIMER: preCharge Risk Management is not responsible for any opinions, advice or comments expressed on the preCharge Community Forums.
preCharge® is a registered trademark of preCharge Risk Management | chargeback protection | Merchant Account Blog

Powered by vBulletin
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC6

Myspace Layouts | Magazine Subscriptions | Bad Credit Mortgages | Reptile Shop | Internet Advertising

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49