插入语法错误

时间:2013-11-12 15:35:04

标签: ms-access sql-insert oledbcommand

我在oledbcommand中有这个sql命令:

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

我收到语法错误但是当我将其复制到访问并运行时,它会运行。

3 个答案:

答案 0 :(得分:2)

应该是:

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

所以你忘记了INTO

答案 1 :(得分:2)

如果您仍然遇到INSERT INTO错误,则问题可能是reserved words字段名称:user;和描述。

将这些名称括在方括号中,以避免混淆数据库引擎。

in_reply_to_screen_name,[user],id_str1

保留字令人沮丧。它们可能并不总是为Access应用程序会话中的查询运行造成麻烦。但是使用OleDb从Access外部运行的查询似乎不太容忍保留字。

答案 2 :(得分:0)

以下是我在SQL语句中看到的错误:

  1. 您需要使用INSERT INTO tweets代替insert tweets
  2. 我猜你真的不想要一串 'null' 而是 希望该字段为 Null 。请勿使用'
  3. 您正在添加 'false' 字符串,我猜你真的想要 该字段为 False 。所以你不会把'放在它周围。
  4. 您还有一些数字要添加为字符串而不是 数字。如果它们确实应该是数字,请不要将它们包裹在'
  5. 您的日期格式似乎无效。
  6. 因此,通过以上所有更改,您的查询可能如下所示:

    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'
    )
    
相关问题