To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here

HOME News MS SQL Oracle DB2 Access MySQL PHP Scripts Books Links DBA Talk


Go Back   Database Journal Forums > Related Sites > SQL Course

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

Reply Post New Thread
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 01-23-2003, 11:22 AM
keinloffel keinloffel is offline
Junior Member
 
Join Date: Jan 2003
Posts: 2
Question 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
Reply With Quote
  #2  
Old 01-23-2003, 01:12 PM
bannor bannor is offline
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 & ")"
Reply With Quote
  #3  
Old 02-05-2003, 04:03 PM
Rawhide's Avatar
Rawhide Rawhide is offline
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 & "');"
Reply With Quote
Reply Post New Thread

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 02:39 PM.


DatabaseJournal Recent Articles


 » Grouping with SQL Server 2008

 » Conducting Service Broker Conversation Usi...

 » SQL Server Consolidation Initiative Under ...

 » Transaction Log Growth, do you need it?

 » New FileMaker Pro 10 Ships With Sleek New ...

Search Database Journal:
 





Acceptable Use Policy

JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers

Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.