Question

I have this sql command in oledbcommand :

insert into tweets(iso_language_code,created_at,id_str,textbody,truncated,in_reply_to_status_id_str,in_reply_to_user_id_str,in_reply_to_screen_name,user,id_str1,username,screen_name,location,description,url,description1,followers_count,friends_count,listed_count,created_at1,favourites_count,utc_offset,time_zone,geo_enabled,verified,statuses_count,lang) values ('en','Tue Nov 05 234107 +0000 2013','397871229903716353','TrophyManager','false','null','null','null','','1401457136','DE-football','football_bot_DE','','Football news in German \/ Fu\u00dfball Nachrichten auf Deutsch\r\n#football #Fussball #German #Germany #Deutsch #Deutschland #Bundesliga #Followback #TeamFollowBack','urlhttp\/\/t.co\/vwBeatWiSO','urls','2948','2866','2','Sat May 04 051820 +0000 2013','0','3600','Berlin','false','false','13074','en')

I get syntax error but when i copy it to access and run, it runs.

Was it helpful?

Solution

If you still get an error with INSERT INTO, the problem may then be due to reserved words as field names: user; and description.

Enclose those names in square brackets to avoid confusing the db engine.

in_reply_to_screen_name,[user],id_str1

Reserved words are frustrating. They may not always create trouble for a query run within an Access application session. But queries run from outside Access using OleDb seem less tolerant of reserved words.

OTHER TIPS

It should be:

INSERT INTO Table_Name (column1,colum2,etc) VALUES (value1,value2,etc.);

So you forgot the INTO

Here are the things I see wrong with your SQL statement:

  1. You need to use INSERT INTO tweets instead of insert tweets
  2. I am guessing you really don't want a string of 'null' but rather would like the field to be Null. Don't use '.
  3. You are adding a string of 'false' and I am guessing you really want the field to be False. So you would not put the ' around it.
  4. You also have some numbers that you are adding as strings instead of numbers. If they really should be numbers don't wrap them in '.
  5. The format of your date does not appear to be valid.

So with all of the above changes your query might look like:

INSERT INTO tweets
(
  iso_language_code, created_at, id_str, textbody, 
  truncated, in_reply_to_status_id_str, in_reply_to_user_id_str, 
  in_reply_to_screen_name, [user], id_str1, username, screen_name,
  location, [description], url, description1, followers_count, friends_count,
  listed_count, created_at1, favourites_count, utc_offset, time_zone,
  geo_enabled, verified, statuses_count, lang
) 
VALUES (
  'en', CDATE('2013-11-05 23:41:07'), 397871229903716353,
  'TrophyManager', False, Null, Null, Null, '', 1401457136, 'DE-football',
  'football_bot_DE', '', 
  'Football news in German \/ Fu\u00dfball Nachrichten auf Deutsch\r\n#football #Fussball #German #Germany #Deutsch #Deutschland #Bundesliga #Followback #TeamFollowBack',
  'urlhttp\/\/t.co\/vwBeatWiSO', 'urls', 2948, 2866, 2,
  'Sat May 04 051820 +0000 2013', 0, 3600, 'Berlin', False, False,
  13074, 'en'
)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top