字段f1就是主键吧,关键就是如何查找主键,对吧。如何获取一张ACCESS表的主键字段名?---------------uses ComObj;function GetPrimary(const DBName, TableName:String; var FieldName: WideString): Boolean;var dbe, dbs, tdf, idx: OleVariant; i, j: Integer;begin Result := False; FieldName:=''; try dbe := CreateOleObject('DAO.DBEngine.36'); dbs := dbe.OpenDatabase(DBName); tdf := dbs.TableDefs[TableName]; for i := 0 to tdf.Indexes.Count - 1 do if tdf.Indexes.Primary then begin idx := tdf.Indexes; for j := 0 to idx.Fields.Count - 1 do FieldName:=FieldName+';'+idx.Fields[j].Name; system.Delete(FieldName,1,1); Result:=True; Break; end; finally if not VarIsEmpty(dbs) then dbs.Close; idx := Unassigned; tdf := Unassigned; dbs := Unassigned; dbe := Unassigned; end;end;procedure TForm1.Button2Click(Sender: TObject);var FieldName: WideString;begin if GetPrimary('C:/db1.mdb', '表一', FieldName ) then caption:=FieldName;end;