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与其它表关联的...
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与其它表关联的...
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;
adoquery1.ParamCheck := false;
只是这两句还没明白是什么意思为什么要加上它们....
不加上还不行...