with ADOQuery3  do
     begin
       SQL.Clear;
       SQL.Add('insert into accountcount(itembm,kjnf) select itembm,''+g_kjyf+'' from iteminfo where itembm not in (select itembm from accountcount where kjnf=''+g_kjnf+'')');
       execsql;
       close;
     end;将varchar值'+g_kjnf+'转换为数据类型为smallint的列时发生语法错误 
上面的搞错了,是这个数据查询,g_kjyf是变量,word类型

解决方案 »

  1.   

    delphi里,把smallint 用 inttostr 转成字符串才能拼接
      

  2.   

         with ADOQuery3  do
         begin
           SQL.Clear;
           SQL.Add('insert into accountcount(itembm,kjnf) select itembm,''+g_kjyf+'' from iteminfo where itembm not in (select itembm from accountcount where kjnf=''+g_kjnf+'')');
           execsql;
           close;
         end;
    将varchar值'+g_kjnf+'转换为数据类型smallint的列时发生语法错误
      

  3.   

    g_kjyf 、g_kjnf 这两个都是变量把,前面是word 后面是 smallintSQL.Add(
        'insert into accountcount(itembm,kjnf) select itembm,'
        + IntToStr(g_kjyf)
        + ' from iteminfo where itembm not in (select itembm from accountcount where kjnf='
        + IntToStr(g_kjnf)
        + ')'
    );