问题
I read in a tutorial written to Delphi 6 : to install ADOX components, select from the main menu Project\Add type Library menu item. But in Delphi XE4 there is not such a menu item. How could I install/use ADOX components in Delphi XE4 to create an empty mdb database programatically? Or is there any other way to create it without ADOX?
回答1:
You could use late binding without importing the type library e.g.:
uses ComObj;
procedure CreateNewMDB(const FileName: WideString);
var
AdoX: OleVariant;
begin
AdoX := CreateOleObject('ADOX.Catalog');
AdoX.Create('Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;Data Source=' + FileName);
end;
If this is all you need, I think it's not worth the effort of importing the ADOX type library.
回答2:
Add type library
was an option in older versions of Delphi. In more modern versions, go to Component > Import Component
instead, where it has the option to Import a Type Library
.
来源:https://stackoverflow.com/questions/41896861/how-can-i-use-adox-components-in-delphi-xe4