我用的是Delphi+ADO+Access,从A表select出四个字段的值,均为text类型,想写入B表,程序如何写。我运行时老说‘标准表达式中类型不匹配’。

解决方案 »

  1.   

    补充一点,select出的数据有很多条
      

  2.   

    insert into b select * from a
      

  3.   

    表A中有六个字段,分别为a,b,c,d,e,f,表B中有四个字段,分别为b,c,d,e.除a以外均为文本类型,a为整型
     ADOQuery1.Close;
     ADOQuery1.SQL.Clear;
     ADOQuery1.SQL.Add( 'insert into B select b,c,d,e from A where b=207 and f=5');
     ADOQuery1.ExecSQL;
    运行时老说‘标准表达式中类型不匹配’
    问题在哪里那
      

  4.   

    select * into table2 from tabl1
      

  5.   

    insert into B (b,c,d,e)
    select b,c,d,e from A where b=207 and f=5
      

  6.   

    你的 b 和 f 是字符型,在delphi 应该是这样写的'insert into B select b,c,d,e from A where b='+'''207'''+' and f='+'''5''');
      

  7.   

    ADOQuery1.SQL.Add( 'insert into B(b,c,d,e) select b,c,d,e from A where b=''207'' and f=''5''');
      

  8.   

    ADOQuery1.SQL.Add( 'insert into B select b,c,d,e from A where b=207 and f=5');
    有错误
    该成:ADOQuery1.SQL.Add( format('insert into B select b,c,d,e from A where b=%d and f=%d,[207,5]));
      

  9.   

    var
    sqlstr:string;ADOQuery1.Close;
    begin
      sqlstr:='insert into B select b,c,d,e from A where b='+'''207'''+' and  'f='+'''5'''';
     with ADOQuery1 do
     begin
      close;
      SQL.Clear;
      SQL.Add( sqlstr);
      ExecSQL;
     end;
    已经调试通过,可以直接使用 :)
    end;