0

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.

3
  • 1
    "when i copy it to access and run, it runs." Check again. That cannot run without INTO following INSERT Commented Nov 12, 2013 at 15:40
  • I also try with into and get error. Commented Nov 12, 2013 at 15:44
  • 1
    Is it then the same error or a different error? Commented Nov 12, 2013 at 15:45

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

Comments

2

It should be:

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

So you forgot the INTO

Comments

0

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'
)

2 Comments

'Tue Nov 05 234107 +0000 2013' isn't a format I'm familiar with either. If that's a date field, there could be problems.
@LittleBobbyTables, I updated my answer to reflect your date format issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.