Board index » delphi » creating a new database file.

creating a new database file.

How do i create a blank database file from a delphi program?
Is it possible? and what is the command required?

Thanks.

 

Re:creating a new database file.


In article <35b2f49...@news.{*word*104}way.com.sg>, The Dummy
<the_du...@bigfoot.com> writes

Quote
>How do i create a blank database file from a delphi program?
>Is it possible? and what is the command required?

Yep - the TTable class makes this fairly straightforward using
the CreateTable method. Basically you set all of the properties
of the table (DatabaseName, TableName, TableType etc), then
set the FieldDefs and IndexDefs as required. After that just
call CreateTable to create the file.

Look in the Help under TTable.CreateTable for an example.
--
Jeremy Collins
Kansai Business Systems

(return address not altered 'coz I get spammed *whatever* I do!)

Re:creating a new database file.


If you use TQuery, and set the SQL property (at design-time or run-time) to
a SQL DDL (Data Definition Language) statement, you can create/delete/update
tables.  SQL is a really powerful database definition and manipulation
language, and I would recommend that you acquaint yourself with it.  It
allows you much more run-time flexibility than changing TTable porperties at
run-time.

Check out SQL DDL and DML in Delphi help.  You'll be doing something like
this:

{Q : TQuery;}

Q.SQL := 'CREATE TABEL (NAME VARCHAR(30), PHONE VARCHAR(10), CONSTRAINT
PRIMARY KEY (NAME));';
Q. ExecSQL;

Note - with TQuery, use Open when performing a SELECT statement (DML) and
ExecSQL when using DDL (eg. CREATE TABLE, DROP TABLE, INSERT INTO, DELETE
FROM, etc)

Any further questions on SQL, just email or post.

Digit

Quote
The Dummy wrote in message <35b2f49...@news.{*word*104}way.com.sg>...
>How do i create a blank database file from a delphi program?
>Is it possible? and what is the command required?

>Thanks.

Re:creating a new database file.


Check out the Borland (Inprise) web site TI documents. You'll find good
examples.  Otherwise, you could use

Re:creating a new database file.


Re:creating a new database file.


Quote
David M. Goncalves wrote:

> Check out the Borland (Inprise) web site TI documents. You'll find good
> examples.  Also ALWAYS FIRST check out http://www.dejanews.com and filter for comp.lang.pascal.delphi.* when asking very basic questions. The question you ask has been asked about a kaJILLION times before, and DejaNews will give you immediate results (rather than you having to wait for a reply)

Check out the TQuery.ExecQuery method (and table structure modification
SQL syntax).
I personally use TTable.Fielddefs.add and TTable.CreateTable methods
(although TTable.fielddefs.add does not give precise control over
numeric field sizes). If a copy of the table alreay exists, you could
use TBatchmove, also.

Regards,
David M. Goncalves

Re:creating a new database file.


Re:creating a new database file.


Hi,
As I think Jeremy Collins had in mind this promblem :
  How create DATABASE (not table of database)
  so HOW run DML similar to " CREATE DATABASE "employee.gdb";
 as I know there are NO way.

Yes  its not good manner , but I cant to do this....

with best regards Dennis Anichkin

Ukraine, Kiev.

Quote
Jeremy Collins wrote in message ...
>In article <35b2f49...@news.{*word*104}way.com.sg>, The Dummy
><the_du...@bigfoot.com> writes
>>How do i create a blank database file from a delphi program?
>>Is it possible? and what is the command required?

>Yep - the TTable class makes this fairly straightforward using
>the CreateTable method. Basically you set all of the properties
>of the table (DatabaseName, TableName, TableType etc), then
>set the FieldDefs and IndexDefs as required. After that just
>call CreateTable to create the file.

>Look in the Help under TTable.CreateTable for an example.
>--
>Jeremy Collins
>Kansai Business Systems

>(return address not altered 'coz I get spammed *whatever* I do!)

Re:creating a new database file.


Well, i used very simple and stupid way for creating new db FILE.
And i don't really know, is there simpler way to create db _FILE_.
I pre-created the empty db file, and added to some .res file with rc script,
then i linked the res to executable.
in code i just took the resource and dumped into a file...

;-)

Another Dummy :)

Quote
Dennis Anichkin wrote in message <6p32iq$li...@app0.visti.net>...
>Hi,
>As I think Jeremy Collins had in mind this promblem :
>  How create DATABASE (not table of database)
>  so HOW run DML similar to " CREATE DATABASE "employee.gdb";
> as I know there are NO way.

>Yes  its not good manner , but I cant to do this....

>with best regards Dennis Anichkin

>Ukraine, Kiev.

>Jeremy Collins wrote in message ...
>>In article <35b2f49...@news.{*word*104}way.com.sg>, The Dummy
>><the_du...@bigfoot.com> writes
>>>How do i create a blank database file from a delphi program?
>>>Is it possible? and what is the command required?

>>Yep - the TTable class makes this fairly straightforward using
>>the CreateTable method. Basically you set all of the properties
>>of the table (DatabaseName, TableName, TableType etc), then
>>set the FieldDefs and IndexDefs as required. After that just
>>call CreateTable to create the file.

>>Look in the Help under TTable.CreateTable for an example.
>>--
>>Jeremy Collins
>>Kansai Business Systems

>>(return address not altered 'coz I get spammed *whatever* I do!)

Re:creating a new database file.


Re:creating a new database file.


Hi,
stop,stop, stop ,.......... that i wrote yesterday mean only -
  I want to ask using opportunity : HOW TO CREATE INTERBASE DATABASE FILE
(*.GDB) or ORACLE , INFORMIX etc., DATABASE , IF It possible !!!.

 excuse me for insistence,
 with best regards Dennis Anichkin
 Ukraine, Kiev.

Quote
Dennis Anichkin wrote in message <6p32iq$li...@app0.visti.net>...
>Hi,
>As I think Jeremy Collins had in mind this promblem :
>  How create DATABASE (not table of database)
>  so HOW run DML similar to " CREATE DATABASE "employee.gdb";
> as I know there are NO way.

>Yes  its not good manner , but I cant to do this....

>with best regards Dennis Anichkin

>Ukraine, Kiev.

Other Threads