Board index » delphi » create a new table (ADO)

create a new table (ADO)


2005-01-25 08:21:36 PM
delphi170
Is any way to create a new table in database?
I know about CREATE TABLE and ADOX.Catalog but I want to know how to create
a new table in another way. All what I want is to create some resultset
(Fields.Append) and specify the table name+save/commit - or this is
impossible in ADO?
PS: I don't want to use the CREATE TABLE because syntax for field types is
not same for all databases. And I don't want to use the ADOX because I am not
sure that new version of ADO will be installed for all my end-users...
 
 

Re:create a new table (ADO)

"Mike Shkolnik" <XXXX@XXXXX.COM>writes
Quote
Is any way to create a new table in database?

I know about CREATE TABLE and ADOX.Catalog but I want to know how to
create
a new table in another way. All what I want is to create some resultset
(Fields.Append) and specify the table name+save/commit - or this is
impossible in ADO?

PS: I don't want to use the CREATE TABLE because syntax for field types is
not same for all databases. And I don't want to use the ADOX because I'm
not
sure that new version of ADO will be installed for all my end-users...
--
With best regards, Mike Shkolnik
EMail: XXXX@XXXXX.COM
www.scalabium.com

Hi Mike,
I'm slightly confused.
i) If you generate a table via field definitions and then hope to be able to
create it in the underlying database, aren't you doing exactly what ADOX is
there for?
ii) Catalog objects and the tables collection should be readily supported by
almost any version of ADOX, so I'd be surprised if you needed your users
to have the "latest" version (BTW: For them to get access to the database,
you have to have installed the basic ADO functionality via MDAC anyway)
iii) If you really want to move out of ADO, you could use the DAO objects
and create a table with them (MS doesn't recommend this approach and it does
restrict you to the JET engine).
Or, maybe I am missing the point of your question...
Andrew
 

Re:create a new table (ADO)

Quote
It sounds to me like you just need to do a Select Into query
Not, I want to create the any new table.
I don't want to save the query rersultset as new table...
 

Re:create a new table (ADO)

Quote
i) If you generate a table via field definitions and then hope to be able
to
create it in the underlying database, aren't you doing exactly what ADOX
is
there for?
As I remember, the ADOX is not installed with old ADO/MS Jet
Or do you want to say that any ADO setup includes the ADOX.Catalog?
Quote
iii) If you really want to move out of ADO, you could use the DAO objects
I don't want to move from ADO. I want to use the pure ADO, not ADOX.Catalog
or any database DDL (like CREATE TABLE)
In DAO I can create a table using
CreateTableDef+CreateField+TableDefs.Append. I need the analogue for ADO
 

Re:create a new table (ADO)

"Mike Shkolnik" <XXXX@XXXXX.COM>writes
Quote
>i) If you generate a table via field definitions and then hope to be able
to
>create it in the underlying database, aren't you doing exactly what ADOX
is
>there for?
As I remember, the ADOX is not installed with old ADO/MS Jet
Or do you want to say that any ADO setup includes the ADOX.Catalog?

>iii) If you really want to move out of ADO, you could use the DAO objects
I don't want to move from ADO. I want to use the pure ADO, not
ADOX.Catalog
or any database DDL (like CREATE TABLE)
In DAO I can create a table using
CreateTableDef+CreateField+TableDefs.Append. I need the analogue for ADO
--
Mike,
According to Microsoft, all versions of the MDAC release have included ADOX.
As ADO and ADOX are installed as part of the operating system from Windows
ME upwards, it would seem sensible to use the Catalog object form ADOX to do
what you want.
As you have found, ADO does not have any routines for the creation /
modification of underlying database objects - that is what ADOX is for.
Cheers,
Andrew
 

Re:create a new table (ADO)

Analog for ADO is ADOX.Catalog/ADOX.Table. ADOX is included at least from
ADO 2.1. But ADOX is not supported by all providers. The most general way is
CREATE TABLE.
//------------------------------------------
Regards,
Vassiliev V. V.
www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)
"Mike Shkolnik" <XXXX@XXXXX.COM>сообщи?сообщила ?новостях
следующе? news:XXXX@XXXXX.COM...
Quote
>i) If you generate a table via field definitions and then hope to be able
to
>create it in the underlying database, aren't you doing exactly what ADOX
is
>there for?
As I remember, the ADOX is not installed with old ADO/MS Jet
Or do you want to say that any ADO setup includes the ADOX.Catalog?

>iii) If you really want to move out of ADO, you could use the DAO objects
I don't want to move from ADO. I want to use the pure ADO, not
ADOX.Catalog
or any database DDL (like CREATE TABLE)
In DAO I can create a table using
CreateTableDef+CreateField+TableDefs.Append. I need the analogue for ADO
--
With best regards, Mike Shkolnik
E-mail: XXXX@XXXXX.COM
WEB: www.scalabium.com


 

Re:create a new table (ADO)

Andrew,
Quote
According to Microsoft, all versions of the MDAC release have included
ADOX.
I found the information that ADOX inclused in MS Jet from v2.1 only
But old versions (1.5, for example) are without ADOX (IMHO).
Quote
As ADO and ADOX are installed as part of the operating system from Windows
ME upwards
But what to do with old Windows 95/98/NT 3/4?
Quote
As you have found, ADO does not have any routines for the creation /
modification of underlying database objects - that is what ADOX is for.
I can create the resultset with required fields in memory (in pure ADO on
client side) but I don't know how to "save" this resultset as table in ADO
connection...
 

Re:create a new table (ADO)

Quote
The most general way is CREATE TABLE.
How to detect the syntax for field types for CREATE TABLE (for any ADO
connection)?
Some databases use the own field types (autoinc, currency, image etc) and
how can I generate the SQL if I don't what is a target database in ADO
connection?
 

Re:create a new table (ADO)

"Mike Shkolnik" <XXXX@XXXXX.COM>writes
Quote
Andrew,
>As ADO and ADOX are installed as part of the operating system from
>Windows
>ME upwards
But what to do with old Windows 95/98/NT 3/4?
I'd just distribute mdac_typ.exe (free download from Microsoft) and install
it along with my software.
Quote
>As you have found, ADO does not have any routines for the creation /
>modification of underlying database objects - that is what ADOX is for.
I can create the resultset with required fields in memory (in pure ADO on
client side) but I don't know how to "save" this resultset as table in ADO
connection...

I've written a couple of freeware components that assist with this sort of
thing: members.ozemail.com.au/~abaylis/downloads.htm
HTH
Andrew
 

Re:create a new table (ADO)

When possible, use common type names. If there is no common type name,
explore siProviderTypes schema - it provides information about types
supported by current provider. There is also schema siDBInfoLiterals that
contains information about quoting and valid characters for table/column
names.
ADO does not process SQL itself and it is possible for provider to use
non-SQL custom syntax. It is possible that provider does not allow create
tables at all.
//------------------------------------------
Regards,
Vassiliev V. V.
www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)
"Mike Shkolnik" <XXXX@XXXXX.COM>сообщи?сообщила ?новостях
следующе? news:41f76452$XXXX@XXXXX.COM...
Quote
>The most general way is CREATE TABLE.
How to detect the syntax for field types for CREATE TABLE (for any ADO
connection)?
Some databases use the own field types (autoinc, currency, image etc) and
how can I generate the SQL if I don't what is a target database in ADO
connection?

--
With best regards, Mike Shkolnik
EMail: XXXX@XXXXX.COM
www.scalabium.com