ADO - como fazer upgrade do dbase ou paradox |
Top Previous Next |
/// How to make migrating from Paradox to ADO easier.
When you consider to migrate your existing paradox application to ADO there are a few things that your should keep in mind.
1. Delphi 5 Update ------------------------------------------------------------------------
Under all circumstances you should get a copy of the Delphi 1 Update Pack. This update eliminates quite a few problems.
2. Using TADOTable or TADOQuery ------------------------------------------------------------
Forget about TADOTable. In most cases consider using TADOQuery instead. Your master detail relationships will work much better using TADOQuery. TADOTable has problems with server side cursor (under Access). When setting up master detail relationships Delphi will set the IndexFieldNames property. With this property set to anything except '' you won't be able to open the table anymore. You could delete this property but Delphi would set it again next time you open the Table.
When using TADOTable make sure that the TableDirect Property is set to TRUE otherwise any sorting order will be ignored.
3. Using server side or client side cursor? ------------------------------------------------
If the number of records in your table is limited (i would say no more than 1000 records) you should use client side cursor. Otherwise using client side cursor will be unacceptable. The time for loading and even opening the table is extremely high because delphi fetches ALL records and caches it on your local machine. Unfortunately client side cursors are much more flexible.
4. Creation order --------------------------------------------------------------------------
For master detail relationships always create the master table / query first. Otherwise the detail table will not be updated at runtime.
5. Parameters -----------------------------------------------------------------------------
Using parameters with ADO is not much fun. Instead of writing
TableABC.ParamByName('CUSTNO').AsInteger := Anything
write
TableABC.Parameters.ParamValues['CUSTNO'] := Anything.
In addition if you would like to modify your SQL-Query within your sourcecode don't forget to add
Parameters.ParseSQL(TableABC.SQL.Text,TRUE);
Otherwise you will get an error message telling you the the parameter could not be found. You parameter name (corrosponding to a field in the master table) should be different from any field name in the detail table.
master (table customer):
NR CUSTNO NAME ...
detail (table order):
NR CUSTNO ORDERNO ...
detail sql: select * from order where CUSTNO = :NO;
This is fine with paradox. Using ADO the NR-field of the detail table will set set to the same value as the NR-field of the master table (customer). You will only get an error message if the primary key nr in the master table already exists in the detail table.
Inserting records, especially in complex master detail relationships, will take more time than in paradox. However querys will open much faster even if you do not have indices for the selected field in your order clause. |