How can I use ADOX components in Delphi XE4?

*爱你&永不变心* 提交于 2019-12-12 02:31:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!