|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
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
|
|
#2
|
|||
|
|||
|
<i><b>Originally posted by : Steve Schofield (sschofield@aspfree.com)</b></i><br />Sorry about blowing your question away! when inserting numbers you don't need single quotes around it. when inserting into a bit field its either a 1 or 0. <br /><br />steve<br /><br /><br />------------<br />Mike Horton at 1/29/00 7:26:44 PM<br /><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
|
|
#3
|
|||
|
|||
|
<i><b>Originally posted by : Mike Horton (mhorton@planet.eon.net)</b></i><br /><br />Thanks Steve. No problem on blowing the question away. I tried what you mentioned and it was still giving me the error. It wasn't until I took the space out of the field names (First Name) that I was able to get it working.<br /><br />Thanks again<br />Mike<br /><br />------------<br />Steve Schofield at 1/29/00 7:38:55 PM<br /><br />Sorry about blowing your question away! when inserting numbers you don't need single quotes around it. when inserting into a bit field its either a 1 or 0. <br /><br />steve<br /><br /><br />------------<br />Mike Horton at 1/29/00 7:26:44 PM<br /><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
|
|
#4
|
|||
|
|||
|
<i><b>Originally posted by : steve schofield</b></i><br />Thanks for taking time to post the answer! I believe these forums will definately better than what we used in the past!<br /><br />steve<br /><br /><br />------------<br />Mike Horton at 1/29/00 10:08:50 PM<br /><br /><br />Thanks Steve. No problem on blowing the question away. I tried what you mentioned and it was still giving me the error. It wasn't until I took the space out of the field names (First Name) that I was able to get it working.<br /><br />Thanks again<br />Mike<br /><br />------------<br />Steve Schofield at 1/29/00 7:38:55 PM<br /><br />Sorry about blowing your question away! when inserting numbers you don't need single quotes around it. when inserting into a bit field its either a 1 or 0. <br /><br />steve<br /><br /><br />------------<br />Mike Horton at 1/29/00 7:26:44 PM<br /><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
|
![]() |
| Viewing: ASP Free Forums > Programming > ASP Development > SQL INSERT INTO and Numbers |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|