Subject |
Re: Should SQL be in same directory as tables? |
From |
Mervyn Bick <invalid@invalid.invalid> |
Date |
Tue, 29 Aug 2023 16:13:47 +0200 |
Newsgroups |
dbase.getting-started |
On 2023/08/29 09:06, Rouke Bakker wrote:
> I'm struggling to convert dbase5.7 to dbase 2019 so am starting from scratch.
>
> I created an SQL containing one table. Double clicking the sql in the navigator shows the tablecorrectly.
>
> When I create a new form in the form designer and drag that same sql onto the designer, I get the message: "Database Engine Error: Table does not exist: C:\admin\database\expenses\EXPENSES.DBF".
>
> I agree with the message; the table sits in C:\admin\database\EXPENSES.DBF, but why does the form look in C:\admin\database\expenses\EXPENSES.DBF (where the SQL resides and from where I clicked new form) while I have specified the table in the sql designer as residing in C:\admin\database\EXPENSES.DBF?
It needs a bit more digging before I stick my neck out and formally
announce a bug but things are definitely a bit "funny". :-(
The -- comment at the top of the .sql file, which identifies the
database or the folder containing the table(s) appears to be for use by
the SQL Designer and dBASE ignores it.
If your form, the SQL file and your tables are all in the same folder
there is no problem other than the fact that this is not considered to
be good programing. Build the SQL file, drag it onto a form and away
you go.
If your tables are not in the same folder as the form and the SQL file,
create a BDEAlias for the table's folder using BDEADMIN. The SQL
designer does NOT recognise a UseBDEAlias. :-( Open the SQL designer
from the same folder as your form and select the BDEAlias. Build the SQL
file from the available tables and save the .sql file.
If you drag the new SQL file onto a form dBASE will stream out a
database object and a query object. Both are set active This looks OK
but if you datalink a grid to the query the grid shows the column
headings but no records.
Instead of dragging the SQL file onto the form drag a database object
and a query object to the form from the Component Palette. Set the
database object's databasename property and make the component active.
Set the query's database and sql properties and make it active. This
should work.
There is one 'caveat'. A while back I triumphantly announced a new bug.
The only problem was that no one else could replicate it and what
wouldn't work on my computer worked for them. There was, therefore,
absolutely no need for my work-around.
If you are going to rewrite applications from scratch now is a good time
to think about switching from .dbf files and the BDE for your tables to
a proper SQL server and ADO. Firebird, which is a fork from the
original Borland Interbase which used to be bundled with early versions
of dBASE, is a good choice but, quite frankly, any SQL server is better
than sticking with the BDE. There is a learning curve and writing to
the database needs a different approach. Once you've mastered SQL
though it opens up powerful options which are not available in dBASE.
You may, of course, never need these options but it is better tho have
them available and not use them than the other way round. :-)
Mervyn.
|
|