Board index » delphi » Create a new Access .MDB from Delphi??

Create a new Access .MDB from Delphi??

I am wondering how to create a new .MDB file from within Delphi.  I do not
need to add any tables or queries at this point, just to create the file so
I can hook my database object to it.

I am using this as a place to write the results of a series of calculations
when a flag is turned on to specify debug mode.

ny help would be greatly appreciated.

Chris.

 

Re:Create a new Access .MDB from Delphi??


I am using Delphi 4.  Where do I find the components or add-ins needed to
get the ADOX_TLB.DCU.

I do not seem to have it.

Quote
>uses
>  ADOX_TLB;

Re:Create a new Access .MDB from Delphi??


Quote
"Chris Blain" <c_bl...@e{*word*277}.com> wrote in message news:39ad25b8_2@dnews...
> I am wondering how to create a new .MDB file from within Delphi.  I do not
> need to add any tables or queries at this point, just to create the file
so
> I can hook my database object to it.

uses
  ADOX_TLB;

const
  BaseName = 'Dummy.mdb';

var
  Catalog: _Catalog;
  DS: string;

begin
  // create a catalog object
  Catalog := CoCatalog.Create;
  // set the connection string
  // note: Engine Type 5 = Access 2000; 4 = Access 97
  DS := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' + BaseName + ';Jet
OLEDB:Engine Type=5';
  // check if we already have such a file and delete it
  if FileExists(BaseName) then
    DeleteFile(BaseName);
  // create new Access database
  Catalog.Create(DS);
end;

--

"Relationships are hard. It's like a full-time job, and we should treat it
like one. If your boyfriend or girlfriend wants to leave you, they should
give you two weeks' notice. There should be severance pay, and before they
leave you, they should have to find you a temp."
Bob Ettinger

Re:Create a new Access .MDB from Delphi??


Quote
"Chris Blain" <c_bl...@e{*word*277}.com> wrote in message

news:39ad5abe$1_1@dnews...

Quote
> I am using Delphi 4.  Where do I find the components or add-ins needed to
> get the ADOX_TLB.DCU.

> I do not seem to have it.

Project / Import Type Library / Microsoft ADO Ext. for DDL and Security
(Version 2.5)

Select 'Generate Component Wrapper' and then 'Create Unit'.  That will
create ADOX_TLB.pas.

If D4 does not automatically list that library add it to the list by finding
C:\Program Files\Common Files\System\ADO\msadox.dll.

--

"Relationships are hard. It's like a full-time job, and we should treat it
like one. If your boyfriend or girlfriend wants to leave you, they should
give you two weeks' notice. There should be severance pay, and before they
leave you, they should have to find you a temp."
Bob Ettinger

Other Threads