Creating tables in code - Help requested 
Author Message
 Creating tables in code - Help requested

I have a need to create some tables for a simple application on a
client/server system. My question is:

Can I create (in code) the table structures then rely on the BDE or
some other sort of interface to physically create these on a server? I
could be creating these on SQL Server, Oracle or Interbase as well as
good ol' Paradox if a server doesn't exist.

If this is too involved for this discussion group can you direct me to
a source of this information?...

I am attempting this using delphi 3x (perhaps soon to be 4) and
version 5 of the BDE.

Thanks for any help.

--------
Bill

Programmer / Analyst
New England Research Institutes

"There are THREE kinds of people in the world...
     Those that CAN count and those that CAN'T."

             <?>

           \\\|///
          \\ ~ ~ //

/-------oOOo-(_)-oOOo--------\



Wed, 18 Jun 1902 08:00:00 GMT  
 Creating tables in code - Help requested


Quote:
>I have a need to create some tables for a simple application on a
>client/server system. My question is:

>Can I create (in code) the table structures then rely on the BDE or
>some other sort of interface to physically create these on a server? I
>could be creating these on SQL Server, Oracle or Interbase as well as
>good ol' Paradox if a server doesn't exist.

>If this is too involved for this discussion group can you direct me to
>a source of this information?...

>I am attempting this using Delphi 3x (perhaps soon to be 4) and
>version 5 of the BDE.

Yes, you can create tables in existing databases at runtime using program
code. You can do this through a number of means.

With the TTable component, use the CreateTable method. Add one TFieldDef
object to the TTable.FieldDefs property (each is a single field's
definition) and then call CreateTable. The online help topic for
CreateTable has a fairly comprehensive example.

With a TQuery, use SQL appropriate for the particular database system used.
The CREATE TABLE statement is used for this and is available in pretty much
every database system. However, the column data types available for use may
vary some from one database system to the next. Put the SQL statement in
the TQuery.SQL property and use the TQuery.ExecSQL method to execute it.

You can also create tables using BDE API functions. The function
DbiCreateTable function is used to actually create the table. Various
structures are used with this operation to define the structure and type of
table.

//////////////////////////////////////////////////////////////////////////
Steve Koterski                      "The knowledge of the world is only to
Technical Publications              be acquired in the world, and not in a
INPRISE Corporation                 closet."
http://www.inprise.com/delphi          -- Earl of Chesterfield (1694-1773)



Wed, 18 Jun 1902 08:00:00 GMT  
 Creating tables in code - Help requested
I have an small program I wrote that configures a new BDE alias for a
SQL Server
Database, and then runs the neccessary scripts to create the Tables,
Users,
Permissions, and Stored Procedures on the Server.

If you are interested I can zip it up and send it to you.

Rkr

Quote:

> I have a need to create some tables for a simple application on a
> client/server system. My question is:

> Can I create (in code) the table structures then rely on the BDE or
> some other sort of interface to physically create these on a server? I
> could be creating these on SQL Server, Oracle or Interbase as well as
> good ol' Paradox if a server doesn't exist.

> If this is too involved for this discussion group can you direct me to
> a source of this information?...

> I am attempting this using Delphi 3x (perhaps soon to be 4) and
> version 5 of the BDE.

> Thanks for any help.

> --------
> Bill

> Programmer / Analyst
> New England Research Institutes

> "There are THREE kinds of people in the world...
>      Those that CAN count and those that CAN'T."

>              <?>

>            \\\|///
>           \\ ~ ~ //

> /-------oOOo-(_)-oOOo--------\

--
                   \|||/
                   /'^'\
                  ( 0 0 )
--------------oOOO--(_)--OOOo--------------
. Reid Roman                              .
. Delphi Programmer / Analyst             .
. TVisualBasic:=class(None);              .
. May the Source be With You              .
-------------------------------------------
. Auto-By-Tel (http://www.autobytel.com)  .
. Irvine, CA U.S.A                        .
. E-Mail : rkroman (at) pacbell (dot) net .
. or reidr (at) autobytel (dot) com       .
-------------------------------------------


Wed, 18 Jun 1902 08:00:00 GMT  
 Creating tables in code - Help requested

Quote:



> >I have a need to create some tables for a simple application on a
> >client/server system. My question is:

> >Can I create (in code) the table structures then rely on the BDE or
> >some other sort of interface to physically create these on a server? I
> >could be creating these on SQL Server, Oracle or Interbase as well as
> >good ol' Paradox if a server doesn't exist.

> >If this is too involved for this discussion group can you direct me to
> >a source of this information?...

> >I am attempting this using Delphi 3x (perhaps soon to be 4) and
> >version 5 of the BDE.

> Yes, you can create tables in existing databases at runtime using program
> code. You can do this through a number of means.

> With the TTable component, use the CreateTable method. Add one TFieldDef
> object to the TTable.FieldDefs property (each is a single field's
> definition) and then call CreateTable. The online help topic for
> CreateTable has a fairly comprehensive example.

> With a TQuery, use SQL appropriate for the particular database system used.
> The CREATE TABLE statement is used for this and is available in pretty much
> every database system. However, the column data types available for use may
> vary some from one database system to the next. Put the SQL statement in
> the TQuery.SQL property and use the TQuery.ExecSQL method to execute it.

> You can also create tables using BDE API functions. The function
> DbiCreateTable function is used to actually create the table. Various
> structures are used with this operation to define the structure and type of
> table.

Steve,

The biggest problem I found in my experience was the use of the MSSQL
keyword
"GO" ...

The only solution I saw was to execute all the scripts in succession;

1. Create Devices (Specifications, Size, Logs, etc..)
2. Create the Database
3. Create Users, Groups
4. Create Tables
5. Create Stored Procedures
6. Set Permissions

And not being allowed to use the keyword "GO" was an obstacle.

I have only thus far used MS SQL Server as a SQL server environment, but
it does allow you to generate scripts to create objects from the
database
individually or as one large script.

It would be nice if there was a component available that would take an
entire script and execute the SQL on MS SQL Server in one pass.

I found that until I find a solution along these lines, the easiest way
was to clear the TQuery.SQL and feed it the necessary doctored up
scripts
by using the LoadFromFile() method passing in the local .SQL files
to get it all to work in an automated way.

Rkr

--
                   \|||/
                   /'^'\
                  ( 0 0 )
--------------oOOO--(_)--OOOo--------------
. Reid Roman                              .
. Delphi Programmer / Analyst             .
. TVisualBasic:=class(None);              .
. May the Source be With You              .
-------------------------------------------
. Auto-By-Tel (http://www.autobytel.com)  .
. Irvine, CA U.S.A                        .
. E-Mail : rkroman (at) pacbell (dot) net .
. or reidr (at) autobytel (dot) com       .
-------------------------------------------



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Invalid table create request

2. Request help on creating D2 DLL forms for use in Access

3. Source code request ! Please Help

4. SQL code for creating a DBF format table

5. Creating new dbIII+ tables from code

6. Code to create table password

7. Creating Database tables in code

8. Creating tables in code, best method

9. Help Requested: Temporary DataSets/Tables...

10. HELP! drop table and create table problems

11. Request: Source code for WinDos.Tpu

12. Request: Code formatter for pascal

 

 
Powered by phpBB® Forum Software