Groups | Blog | Home
all groups > dotnet ado.net > july 2007 >

dotnet ado.net : Need help with SYNTAX Error



Terry Olsen
7/6/2007 10:28:28 PM
I'm getting a SYNTAX error in this statement:

INSERT INTO Usenet (MessageID,Subject,ArticleDate,From,Lines) VALUES (
'<131prkkuk51ed5@news.supernews.com>',
'TG FM - The Eternal Candle - "eternalcandle_v.1.1.zip" 22716KB yEnc
(08/37)',
'4/11/2007',
'None@none.a (Sxerks)',
5082)

I believe it might have something to do with the double-quotes in the
subject or the LessThan & GreaterThan in the MessageID, but I'm not sure.
Can someone point out where I'm going wrong in this statement?

Thanks!

PvdG42
7/7/2007 12:20:02 AM

[quoted text, click to view]
What database engine? SQL Server 2005, SQL Server 2000, Oracle, etc.?
What are the data types of the fields in the table?
And, exactly what is the error message you are getting?
Kerry Moorman
7/7/2007 7:22:01 AM
Terry,

"From" is a reserved word in Access. You will need to change the name of the
column.

Kerry Moorman


[quoted text, click to view]
Terry Olsen
7/7/2007 8:13:32 AM
MDB file, using OLEDB. The error is "SYNTAX error in statement"

[quoted text, click to view]

Rad [Visual C# MVP]
7/7/2007 7:41:33 PM
On Fri, 6 Jul 2007 22:28:28 -0600, "Terry Olsen"
[quoted text, click to view]

1) What is the syntax error?
2) User parameterized queries ... they'll shield you from all the
associated problems of escaping strings, formatting of date values,
etc

--
Sergey Poberezovskiy
7/8/2007 3:14:02 PM
Terry,

As Kerry said, "From" is a reserved word, and cannot be used in this context.
However, you do not need to rename the column in the table - just wrap the
column name in square brackets in your insert statement:
[From]

hope this helps

[quoted text, click to view]
AddThis Social Bookmark Button