Recent

Author Topic: Porting from Borland Delphi BDE TQuery, TTable, TDatabase, TSession, etc  (Read 20045 times)

PStechPaul

  • Jr. Member
  • **
  • Posts: 76
    • P S Technology, Inc.
I'm trying to port the database units of my Ortmaster project (created with Delphi 4 Pro) to Lazarus, and it needs equivalents for TQuery (which I changed to TSQLQuery) and TTable (for which I found no equivalent, and possibly others. I am using dBase format (III, III+, IV?). I can change the references in the PAS and DFM files so they will appear in the form designer, and then I can change or add Lazarus database components. I'm not especially clear on some database concepts, but I'm not doing anything very exotic. Mostly adding and editing records and extracting data for analysis and reports. Thanks!

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
TDbf is a TTable component for dBase files.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

Zath

  • Sr. Member
  • ****
  • Posts: 391
Did the TSQLQuery work instead of TQuery ?
What else did you need to change for this to work ?
I have the same problem moving an old legacy D7/D2007 project into a newer version.

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
In order to have a reliable Paradox or DBF application, you need to flush after each write, and if you use indexes then to avoid corruption you need to detect if your application has ended properly, and if not (there was reset or power down) then you need to reindex on application initialization.

All these can be avoided if you move to transactional database, for example SQLite or Firebird embedded, but that needs significant changes in code and the way of thinking.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
@Avra:
TOdbcConnection makes the lot transactable (requires an odbc driver for dBase but these are common.)
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Did the TSQLQuery work instead of TQuery ?
What else did you need to change for this to work ?
I have the same problem moving an old legacy D7/D2007 project into a newer version.

No. TSqlQuery is NOT going to work. These older dBase's have no concept of SQL.
TDbf on the other hand can work as either/or/and ttable and tquery.

The other option is to use ODBC with a dBase driver.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

korba812

  • Sr. Member
  • ****
  • Posts: 394
Advantage Database can work with dbf and have query component
http://wiki.freepascal.org/Advantage_Database_Server

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
TOdbcConnection makes the lot transactable (requires an odbc driver for dBase but these are common.)
Good point. ODBC was not on my mind when I wrote that.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

PatBayford

  • Full Member
  • ***
  • Posts: 125
Sorry Thaddy, but your comment on SQL is not strictly accurate - older databases, like dBase and Paradox certainly do "talk" art least a limited subset of SQL. In paradox you can even get to see the SQL used to communicate with the database engine, and even write your own.
However, they DO hide this from the user, sometimes too well!
I have no direct experience with TsqlQuery, but suspect it will work provided you stick to using basic, unenhanced SQL.
On the ODBC front can I urge you all strongly to avoid the Microsoft offerings for dBase and Paradox, as personal experience suggests these are fraught with problems. (no doubt the long running feud between MS and Borland is in no way responsible for this!!!)
Lazarus 1.8.0 FPC 3.0.2 SVN 56594 Windows 10 64bit (i386-win32-win32/win64)

PStechPaul

  • Jr. Member
  • **
  • Posts: 76
    • P S Technology, Inc.
I found this, which will probably be helpful:
http://wiki.freepascal.org/Lazarus_Tdbf_Tutorial#Creating_the_table

I was able to get three of the forms to show, for editing. There is also a form for reports, using Quick Reports. I am installing LzReports  - which hopefully will be compatible.

Attached are the three forms I will be working with:
« Last Edit: May 07, 2017, 11:12:07 pm by PStechPaul »

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Nope not compatible. The reports need a rewrite. But the principles are the same.
Many of your issues are very doable, but you seem to have lack of experience in porting based on some of your choices.
I'll see if I can make some time.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

mangakissa

  • Hero Member
  • *****
  • Posts: 1131
If you're very font of your data, use TDBF. Otherwise turn your application on with TBufdataset / tMemdataset and use XML
Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1

Zath

  • Sr. Member
  • ****
  • Posts: 391
Did the TSQLQuery work instead of TQuery ?
What else did you need to change for this to work ?
I have the same problem moving an old legacy D7/D2007 project into a newer version.

No. TSqlQuery is NOT going to work. These older dBase's have no concept of SQL.
TDbf on the other hand can work as either/or/and ttable and tquery.

The other option is to use ODBC with a dBase driver.

Thank you.

PStechPaul

  • Jr. Member
  • **
  • Posts: 76
    • P S Technology, Inc.
I will probably need to keep the dBase III+ format, because there are a lot of these systems installed in the field, and changing the files to another format may be problematic. The dBase format works well enough and is simple. I'm not even using indexes.

At this point I'm going to go through the Lazarus Tdbf tutorial (http://wiki.freepascal.org/Lazarus_Tdbf_Tutorial) and create a simple application that uses those components with one (or all) of my dBase files.

Then I may try to learn LazReport (http://wiki.freepascal.org/LazReport_Documentation).

Thanks for the suggestions. If anyone is interested in putting some time into this project for porting it from Delphi to Lazarus, I'd be willing to pay a reasonable amount. This is an industrial product that needs a fair degree of reliability, as well as a simple and attractive GUI. I have transferred the responsibility for the product to an associate who will be marketing, building, and servicing the product.

It does not necessarily have to be ported to Lazarus. My immediate problem is getting the serial port communication working with Win10, and it seems like the TLazSerial component will do that. I think it should work with D4. But I am impressed with Lazarus and it seems to be actively supported, whereas Delphi has moved far past D4 and even D7, and future maintenance will probably be easier (and much cheaper) than the newer versions of Delphi. But that's another discussion...  8)

mangakissa

  • Hero Member
  • *****
  • Posts: 1131
Quote
This is an industrial product that needs a fair degree of reliability
Okay......
Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1

 

TinyPortal © 2005-2018