ADOQuery1.Close;
 ADOQuery1.SQL.Clear;
 ADOQuery1.SQL.Text:='select * from sheet1 where 编码 notin (select 编码 from [excel 8.0;database=' + path + '].[sheet1$])';
 adoquery1.Parameters.Clear;
 adoquery1.ParamCheck := false;
 ADOQuery1.Open;
运行出错,目的是想查询出excel在access的sheet1表中没有数据....再把这些数据添加到sheet1表中不能用distinct,因为数据的ID与其它表关联的...

解决方案 »

  1.   

    Access支持   notin  这样语句的嘛
      

  2.   

    notin是不是应该加个空格,改成not in这样。
      

  3.   

    notin是不是应该加个空格,改成not in这样。
      

  4.   

    在各位老师帮助下,写的数据更新成功...解决了大问题谢谢.......
    procedure TForm1.Button2Click(Sender: TObject);
    var
     xlspath:string;
    begin
     if Opendialog1.Execute then
      xlspath:=Opendialog1.FileName ;
     ADOQuery1.Close;
     ADOQuery1.SQL.Clear;
     adoquery1.Parameters.Clear;
     adoquery1.ParamCheck := false;
     ADOQuery1.sql.Text:='insert into she(编码,名称,规格,单位,备注) select 编码,'+
     '名称,规格,单位,备注 from [excel 8.0;database=' + xlspath+ '].[sheet1$]'+
     'where 编码 not in (select 编码 from she)';
     ADOQuery1.ExecSQL;
    end;
      

  5.   

    adoquery1.Parameters.Clear;
     adoquery1.ParamCheck := false;
    只是这两句还没明白是什么意思为什么要加上它们....
    不加上还不行...