| SQL Course SQL Course
> Ask questions about the lessons on SQL Course 1 and 2. If you have problems
> with the interface, please post in the Feedback forum |

01-23-2003, 11:22 AM
|
|
Junior Member
|
|
Join Date: Jan 2003
Posts: 2
|
|
This is really dumb
What's the syntax error in this insert statement?
String sql = "INSERT INTO Feedback ( Name, Email, Extn, Date, Description, Alternate, Type) VALUES(" +rname+ ", " +email+ ", " +extn+ ", #" +date+ "#, " +description+ ", " +alternate+ ", " +type+ ")" ;
rname, email etc are all variables I've defined already.
date is a Date
extn is a Number
the rest are all text
the DB I'm using is MS Access.
I'm really rusty on this right now.
Thanks
|

01-23-2003, 01:12 PM
|
|
Registered User
|
|
Join Date: Dec 2002
Posts: 5
|
|
|
If you're doing this in Access, try replacing the + signs with &, and insert a space between it and your variables. Also, you shouldn't need the semi colon at the end.
If I was doing it in ms-access vba I would think the line(s) would look similar to the following
Dim sSql As String
sSQL = "INSERT INTO Feedback (Name, Email, Extn, Date, Description, Alternate, Type) VALUES(" & rname & ", " & email & ", " & extn & ", #" & date & "#, " & description & ", " & alternate & ", " & type & ")"
|

02-05-2003, 04:03 PM
|
 |
Moderator
|
|
Join Date: Feb 2003
Posts: 1,046
|
|
|
In addition to what bannor said, I am assuming that fields like name, email, description, etc., are text fields. Your text needs to be delimited. Also, if you are using the semi-colon because it is Access, put the semi-colon inside the double quotes, not out.
Like this:
sSQL = "INSERT INTO Feedback (Name, Email, Extn, Date, Description, Alternate, Type) VALUES ('" & rname & "', '" & email & "', " & extn & ", #" & date & "#, '" & description & "', '" & alternate & "', '" & type & "');"
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 02:39 PM.
|

DatabaseJournal Recent Articles

|
|