I have a couple of queries about paradox databases and tables and how
they relate to each other and how you use them. My previous experience
with Delphi and database programming is all using MS SQL-Server. In
these cases, the database is rather monolithic and the tables are part
of that but with Paradox there seems to be a collection of tables with
little apparent connection between them. (Hence the titel of the post. I
did not mean to imply that Paradox was not a worthy database.)
I am using Paradox tables but I do not have Paradox installed. I have
re-installed Delphi and I now have the Database desktop which helps. I
have made a few tables using the DD and I need to be able to read from
and write to them in code and I have a couple of queries about how the
BDE finds and manages tables.
Using SQL-Server the way I am used to, I woul set up a TDatabase
component that connects to the database and when I came to query the
database, I would do something like:
Query.DatabaseName = Database.DatabaseName;
Query.SQL.Add('SELECT * FROM .....);
Query.Open;
Using the Paradox tables I have only been able to manage something like
this:
Query.SQL.Add('SELECT * FROM "C:\Files\Table.db"....');
which could get a little messy if or when I move the files or distribute
the program. I know that I could soft-code the working directory like
so:
Query.SQL.Add('SELECT * FROM "' + WorkingDirectory +
'\Table.db"....');
but I was wondering if I am going about it all wrong and there is a
better way to do it. Should I be using aliases? Would they make the
installation of the program more complex or can that be done in code by,
for example, an intallation program?
What, if any, is the role of TDatabase when using Paradox tables and
does the BDE keep tables open or cached or whatever to make updates nice
and quick?
If part of my program (a multi-threaded server) makes updates to one or
more tables can I be reasonably sure that the other parts will get the
freshest data possible or would I need to handle threading and
concurrent access myself to avoid bad data and race conditions?
As this program is (or will be) a server running as an NT service, I can
not use data aware controls which might make the program a little easier
to develop.
If anyone has a demo or example program that uses Paradox tables that
they are willing to share, I would appreciate it if they could point it
out or send it my way.
Thank ouy,
Sraya Malkiel wrote:
> > Using SQL-Server the way I am used to, I woul set up a TDatabase
> > component that connects to the database and when I came to query the
> > database, I would do something like:
> > Query.DatabaseName = Database.DatabaseName;
> > Query.SQL.Add('SELECT * FROM .....);
> > Query.Open;
> >
> You can do the same with Paradox. You just have to take care that the
> Ttables components have they database property set to the a database
> componenet not to an alias.
> Sraya
I have only been using TQuery and I don't plan to use TTable.
What properties of a TDatabase do I need to set in order to use it and how
do I connect a TQuery to it?
Mike
--
Mike Best Programming
Brisbane
Australia
"Anthony Gilbert" <anthony...@rmit.edu.au> wrote in message
news:3A9C9670...@rmit.edu.au...
In Paradox, each table is a separate file (*.db). It may have several
related files such as an index (*.px), memo file (*.mb) etc. All of
the tables and their related files in any particular directory can be
thought of as a database. When you create an alias, you specify its
driver type (Paradox) and the directory that it points to. So an
alias can also be regarded as pointing to a database.
If there are only one or two TQuery components in an application, you
might create an alias (with BDE administrator) pointing to the
directory where your Paradox tables reside. Then you could set the
"DatabaseName" of each TQuery to that alias, either in code or by
selecting it using the dropdown box in the object inspector.
Alternatively, you could omit the alias and use the directory's full
pathname as the "DatabaseName" of the TQuery compnents.
Then you write your sql just as in SQL Server. i.e. Select * from
tablename. (where tablename is the name of the paradox table. There
is no need to include the .db extension - it is optional)
If there are more than a couple of TQuery or Ttable components, you
can use an TDatabase component to manage their connection to the
database. Set the AliasName of the TDatabase to the BDE alias that
points to your Paradox tables. Then set the DatabaseName of the
TDatabase to something descriptive, say "COMPANYDB". In this case,
you would then set the "DatabaseName" property of all the TQuery
components to "COMPANYDB". Now you have the advantage of being able
to change the database that all the components point to just by
setting the AliasName of a single TDatabase component.
Concerning visibility of updates, see the topic
TDatabase.TransIsolation in the help.
I have to question why you chose Paradox? I am not knocking it but
it is nearing the end of its lifespan. Although it is reliable
enough once you learn its quirks, it is not in the same league as a
true client/server database. Since your experience is with MS SQL
Server, have you considered Interbase. It is a true client/server
database with performance comparable to SQL Server but with a much
smaller footprint, almost maintenance-free and runs on Linux, Windows
and Solaris. It is open source and available for free download from
http://www.borland.com/interbase/
You can connect to it via the BDE or ODBC or you can use the free IBX
components to eliminate the BDE and access it directly. ADO drivers
are also becoming available and, unlike Paradox, it will be supported
by Borland's new DBExpress technology in Kylix and Delphi 6.
regards
Colin Acheson
Try this
Query.databasename := 'C:\Files';// you can use an alias, too
Query.SQL.Clear;
Query.SQL.Add('select * from mytable.db');
Query.Open
--
Roman
(please remove 'stopspam' in header when replying)
mail: in...@rksolution.cz
URL: www.rksolution.cz
I recommend not to use Paradox. I had many problems with it and have moved
towards Interbase 6 SQL-Server (free) and use InterbaseExpress Components
that are shipped with Delphi - latest Version 4.51 is available on
http://codecentral.borland.com/codecentral/ccweb.exe/author?authorid=102
Works fine with multithreading and services under NT, 2000, 98 as long as
you use Interbase network connections eg. localhost:C:\anyDatabase.GDB and
NOT local connections eg C:\anyDatabase.GDB
Bernhard Hartl
"Anthony Gilbert" <anthony...@rmit.edu.au> schrieb im Newsbeitrag
news:3A9C78E2...@rmit.edu.au...
Colin gave a fukk answer to this question in his post.
Sraya
> Yes, you probably should be using aliases as they will save you from
> having to hard-code directory names.
I prefer (for Paradox tables) to use a TDatabase as a pseudo alias and
omit the real alias altogether. You can work out the path to the
directory at run time using whatever scheme you want, e.g. default
to the same directory as where the .exe was found, or override that
with a command line parameter.
I recently wrote an article about this.
See http://www.cix.co.uk/~bsparrow/delphi/tdatabase.html.
--Bill Sparrow--
Member of the UK Borland User Group
> Since no-one has addressed the multi-threading part of your question with
> regard to Paradox, I thought I would just say that I have read that each
> thread needs its own Session. I believe the help tells you how do set
> this up, though I haven't looked myself.
>
Thank you. That is the sort of thing that I would have found out the hard way
after much hair-pulling.