C#应用程序中,用如下语句:strSQL="insert into tbl2005 (ID, PubType, Authors, DocTitle, SourceTitle,Language, DocType, AuthorsKeywords,KeywordsPlus, FirstAddress,AuthorsAddress,ReprintAddress,Citation,TimesCited,ISSN,PubDate,PubYear,Volume,Issue,BeginPage,EndPage,Pages,Subject,RuKu ) values ( "+i+",'"+strGetMatching[0]+"','"+strGetMatching[1]+"','"+strGetMatching[2]+"','"+strGetMatching[3]
+"','"+strGetMatching[4]+"','"+strGetMatching[5]+"','"+strGetMatching[6]+"','"+strGetMatching[7]+"','"+strFirst+"','"+strGetMatching[8]+"','"+strGetMatching[9]+"','"+strGetMatching[10]+"','"+strGetMatching[11]+"','"+strGetMatching[12]+"','"+strGetMatching[13]+"','"+strGetMatching[14]+"','"+strGetMatching[15]+"','"+strGetMatching[16]+"','"+strGetMatching[17]
+"','"+strGetMatching[18]+"','"+strGetMatching[19]+"','"+strGetMatching[20]+"','2005' )";以前好好的,现在说是“Insert into 语句语法错误”,设置断点,运行的时候快速监视copy出来,在Access里建立查询能够正常执行(以前程序里也能正常执行);然后修改为:strSQL="insert into tbl2005 values ( "+i+",'"+strGetMatching[0]+"','"+strGetMatching[1]+"','"+strGetMatching[2]+"','"+strGetMatching[3]+"','"+strGetMatching[4]+"','"+strGetMatching[5]+"','"+strGetMatching[6]+"','"+strGetMatching[7]+"','"+strFirst+"','"+strGetMatching[8]+"','"+strGetMatching[9]+"','"+strGetMatching[10]+"','"+strGetMatching[11]+"','"+strGetMatching[12]+"','"+strGetMatching[13]+"','"+strGetMatching[14]+"','"+strGetMatching[15]+"','"+strGetMatching[16]+"','"+strGetMatching[17]+"','"+strGetMatching[18]+"','"+strGetMatching[19]+"','"+strGetMatching[20]+"','2005' )";上午能正常执行,什么都没改,现在运行时出错,捕获异常,为“无当前记录”。并且,另外一条类似的语句:
strSQL1="insert into tbl2005Add (ID,AuthorsAddress,TimesCited,IsFirst,RuKu) values ("+i+",'"+strFirst+"','"+strGetMatching[11]+"','T','2005')";插入到同一个库的另一个表,执行正常,这是怎么回事?

解决方案 »

  1.   

    看看你插入的字符中是不是有什么特殊的字符。你并没有截获到真真的SQL语句。还是C#的语句
      

  2.   

    搞定了,是因为Language这个字段,好像是非保留关键字,改成ALanguage就行了-_-
    可是一直以来都是这么命名的,从来没出过错……
      

  3.   

    其中 strGetMatching[?] 某一个 值为空,那么 insert into t(a,b,c) value (1,,2)
    那么就会报错
      

  4.   

    在access里面有比较多的关键字
      

  5.   

    要养成好习惯,字段一律用[Language]就行了