Board index » delphi » Creating Access MDB in RealTime???

Creating Access MDB in RealTime???

How to Create Access MDB  in RealTime using ADO/D5???

--
Ivan Borissov

 

Re:Creating Access MDB in RealTime???


Ivan,

Here's my routine for creating a new mdb file (note - msadox.dll must be
registered):

<< snip <<
function CreateMDB(const MDBName: string; Password: string = ''): boolean;
var
  v: variant;

begin

  if (FileExists(MDBName)) and not (DeleteFile(MDBName)) then
    raise EFilerError.Create('Could not overwrite database file: ' +
MDBName);
  v := CreateOleObject('ADOX.Catalog.2.5');
  v.Create(
    'Provider=Microsoft.Jet.OLEDB.4.0;' +
    'Password="";' +
    'User ID=Admin;' +
    'Data Source=' + MDBName+ ';' +
    'Mode=ReadWrite;' +
    'Extended Properties="";' +
    'Locale Identifier=1033;' +
    'Jet OLEDB:System database="";' +
    'Jet OLEDB:Registry Path="";' +
    'Jet OLEDB:Database Password="' + Password + '";' +
    'Jet OLEDB:Engine Type=5;' +
    'Jet OLEDB:Database Locking Mode=1;' +
    'Jet OLEDB:Global Partial Bulk Ops=2;' +
    'Jet OLEDB:Global Bulk Transactions=1;' +
    'Jet OLEDB:New Database Password="";' +
    'Jet OLEDB:Create System Database=False;' +
    'Jet OLEDB:Encrypt Database=False;' +
    'Jet OLEDB:Don''t Copy Locale on Compact=False;' +
    'Jet OLEDB:Compact Without Replica Repair=False;' +
    'Jet OLEDB:SFP=False');

end;

Quote
>> snip >>

--
David Reed
White Plains, Maryland USA

*To reply, remove the no_spam from my email address

Re:Creating Access MDB in RealTime???


Oh, it may be obvious, but in case not - make sure ComObj is included in
your "uses" clause.

David

Re:Creating Access MDB in RealTime???


Hi,

Quote
> How to Create Access MDB  in RealTime using ADO/D5???

you can use ADOX (ADO Extension for Data Definition Language and Security) :

uses ADOX_TLB;

resourcestring
  cCONNECTSTRING = 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=';

procedure TFormMain.ButtonCreateClick(Sender: TObject);
var
  aCatalog  : _Catalog;
  sDBPath   : String;
  sDS       : String;
begin
  sDBPath := EditMDB.Text;
  if FileExists(sDBPath) then
     DeleteFile(sDBPath);
  aCatalog := CoCatalog.Create;
  // Create new ACCESS-Database
  sDS := aCatalog.Create(Format('%s%s',[cCONNECTSTRING, sDBPath]));
  ...
end;

Re:Creating Access MDB in RealTime???


Thanks ALL!
Thanks VERY MUCH!!!
--

Ivan Borissov

Quote
Ivan <ikojuha...@bitex.com> wrote in message

news:8ict3e$a9610@bornews.borland.com...
Quote

> How to Create Access MDB  in RealTime using ADO/D5???

> --
> Ivan Borissov

Other Threads