Create Database using DDL (Access 2000)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Have successfully created tables and indices using SQL such as following -

CREATE TABLE OBSERVATIONDATA
( obs_sequence COUNTER,
obs_time DATETIME NOT NULL,
obs_data TEXT(22) WITH COMPRESSION NOT NULL )

CREATE INDEX time ON observationdata(obs_time)

- these were fed in using JET 4 interface in Delphi (ain't legacy code great
:)

Question is - what is SQL syntax for creating an empty database /ex nihilo/
without using the Access UI. I could use a pointer to BNF or other spec for
the language as used in Access.

CREATE DATABASE thedatabase ???

The goal is to eliminate the "empty template" database file from the
software distribution.

-- Mike
 
Mike B in Bedford said:
Have successfully created tables and indices using SQL such as
following -

CREATE TABLE OBSERVATIONDATA
( obs_sequence COUNTER,
obs_time DATETIME NOT NULL,
obs_data TEXT(22) WITH COMPRESSION NOT NULL )

CREATE INDEX time ON observationdata(obs_time)

- these were fed in using JET 4 interface in Delphi (ain't legacy
code great :)

Question is - what is SQL syntax for creating an empty database /ex
nihilo/ without using the Access UI. I could use a pointer to BNF
or other spec for the language as used in Access.

CREATE DATABASE thedatabase ???

The goal is to eliminate the "empty template" database file from the
software distribution.

-- Mike

I don't think you can do that with DDL (but don't know for sure).

You can use ADO/ADOX from Delphi?

Here's a short ADOX sample that should probably work in VBA.

dim cat as ADOX.Catalog
Set cat = New ADOX.Catalog
cat.create "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\test.mdb"

Then, if you fetch the .ActiveConnection from the catalog object,
you could execute your DDL on that connection

With cat.ActiveConnection
.execute "CREATE TABLE myTable....",,adCmdText+adExecuteNoRecords
....
 
RoyVidar said:
in message <[email protected]>: .... ....
I don't think you can do that with DDL (but don't know for sure).

You can use ADO/ADOX from Delphi?

Here's a short ADOX sample that should probably work in VBA.

dim cat as ADOX.Catalog
Set cat = New ADOX.Catalog
cat.create "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\test.mdb"

Then, if you fetch the .ActiveConnection from the catalog object,
you could execute your DDL on that connection

With cat.ActiveConnection
.execute "CREATE TABLE myTable....",,adCmdText+adExecuteNoRecords
....
Thanks, this gives me the direction to search. I'll try to followup when I
come to a solution.
-- Mike
 
Roy Vidar said:
...
Thanks, this gives me the direction to search. I'll try to followup when I
come to a solution.
-- Mike

google: +delphi +jet +create +database

"New...Access Database from Delphi - DB Course/Chapter 13 - Page 2/2
Page 2: The Delphi Project to create a new MS Access database, add
tables, ...
To build a new table with DDL by using the Jet SQL, we use the CREATE
TABLE ...
delphi.about.com/od/database/l/aa072401b.htm - 36k - Nov 16, 2006 -


http://delphi.about.com/od/database/l/aa072401b.htm

... "Our task is to have Delphi do all the work. We want to create a new
database
from code, add all three tables from code, add indexes from code and even
set
up a referential integrity between those tables - again from code.

" ... a TADOXCatalog component (ActiveX page). The TADOXCatalog will do
the trick of creating a new database." ...

and code snippets and pointer to a program which compiles and runs.
http://delphi.about.com/od/database/l/aa072401b.htm

Have imported (cut&paste) code and it runs in my environment.
Thanks again to "RoyVidar"
-- Mike
 
Back
Top