Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 139
  • Last Modified:

Integration with Access - Create DB

I merely want to create an Access Database (NOT Access Project) from Delphi using one of the Server components.
From there on I would probably like to create tables etc...

After trying Borland's help on the Server component's tab without success I tried Access's help - equally disappointing. I'd like a website or document that clarifies the Office type libraries up to the point where I don't have to hack away hours trying to come up with a really simple solution.

Any real help would be appreciated.
Regards
André
0
AndreDicks
Asked:
AndreDicks
1 Solution
 
geobulCommented:
Hi,

Here is a simple solution without using any server component.

uses ComObj;

// Version 3=95, 4=97, 5=2000
procedure CreateAccessDatabase(MDBName: string; Version: integer);
var
  Catalog: Variant;
begin
  Catalog := CreateOleObject('ADOX.Catalog');
  Catalog.Create('Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type='+IntToStr(Version)+';Data Source='+MDBName+';');
end;

// usage:
procedure TForm1.Button1Click(Sender: TObject);
begin
  CreateAccessDatabase('D:\new.mdb',4);
end;

// create a table in it (needs ADOQuery1 component on the form)
procedure TForm1.Button2Click(Sender: TObject);
begin
with ADOQuery1 do begin
  Close;
  ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\new.mdb;';
  SQL.Clear;
  SQL.Add('CREATE TABLE Table1 (Field1 char(20), Field2 integer)');
  ExecSQL;
end;
end;

Regards, Geo
0
 
CleanupPingCommented:
AndreDicks:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now