* * *

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

PStechPaul

  • Jr. Member
  • **
  • Posts: 72
    • 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: 4025
TDbf is a TTable component for dBase files.
"Logically, no number of positive outcomes at the level of experimental testing can confirm a scientific theory, but a single counterexample is logically decisive."

Zath

  • Full Member
  • ***
  • Posts: 241
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: 1049
    • 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 - Easily convert components and projects between Lazarus and CodeTyphon

Thaddy

  • Hero Member
  • *****
  • Posts: 4025
@Avra:
TOdbcConnection makes the lot transactable (requires an odbc driver for dBase but these are common.)
"Logically, no number of positive outcomes at the level of experimental testing can confirm a scientific theory, but a single counterexample is logically decisive."

Thaddy

  • Hero Member
  • *****
  • Posts: 4025
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.
"Logically, no number of positive outcomes at the level of experimental testing can confirm a scientific theory, but a single counterexample is logically decisive."

korba812

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

avra

  • Hero Member
  • *****
  • Posts: 1049
    • 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 - Easily convert components and projects between Lazarus and CodeTyphon

PatBayford

  • New member
  • *
  • Posts: 48
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.6.4 FPC 3.0.2 SVN 54278 Windows 10 64bit

PStechPaul

  • Jr. Member
  • **
  • Posts: 72
    • 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: 4025
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.
"Logically, no number of positive outcomes at the level of experimental testing can confirm a scientific theory, but a single counterexample is logically decisive."

mangakissa

  • Hero Member
  • *****
  • Posts: 689
If you're very font of your data, use TDBF. Otherwise turn your application on with TBufdataset / tMemdataset and use XML
Lazarus 1.64 (32b) / FPC 3.0
Windows 10

Zath

  • Full Member
  • ***
  • Posts: 241
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: 72
    • 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: 689
Quote
This is an industrial product that needs a fair degree of reliability
Okay......
Lazarus 1.64 (32b) / FPC 3.0
Windows 10

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus