Delphi: creating Access DB (.mdb) without access to Ms

Is there a way to create Access databases (.mdb) without actually using Ms Access? I would like my application to create it instead (when the user clicks "New Document" on the toolbar).

I am using Delphi 5 Ent.

Thanks in advance!: -)

+3
source share
2 answers

Yes, there is a way if you use the ADOX library. This is an ActiveX library that you can import into Delphi. Then you can create a new database with the code below. See here .

procedure TForm1.btnNewDatabaseClick(Sender: TObject);
var
 DataSource : string;
 dbName     : string;
begin
 dbName:='c:\aboutdelphi.mdb';

 DataSource :=
    'Provider=Microsoft.Jet.OLEDB.4.0' +
    ';Data Source=' + dbName +
    ';Jet OLEDB:Engine Type=4';

  ADOXCatalog1.Create1(DataSource);
end;
+9
source

Here's how to do it:

procedure CreateNewDatabase;
var
  AdoxCatalog: Catalog;
begin
  AdoxCatalog := CoCatalog.Create;
  AdoxCatalog.Create(ConnectionString
    + 'Jet OLEDB:Engine Type='+IntToStr(Jet4x)+';');
end;

ADOX_TLB, , "Microsoft ADO Ext. 2.8 DDL ".

+2

Source: https://habr.com/ru/post/1771314/


All Articles