On this experience, I prepare the form with 3 database component; TADOConnection, TADOQuery (for MDB) and TTable (for DBF)
For first initialization MDB files using a connection string, here below my example how to get it done:
ADOConnection1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;'+'User ID=Admin;Data Source='+Edit1.Text+';Mode=Share Deny None;'+'Persist Security Info=False;';
While Edit1.Text contains drive name & full path where the MDB file exist on local storage. TADOQuery used to retrieve record using SQL query as usual used on TQuery. But note that the SQL syntax between MDB and others database is not exactly the same. You need to carefully type the correct query or you can test it first from MS Access query window.
After it succeeded, retrieve MDB records using TADOQuery, now turn to DBF migration operation. Sometimes, original DBF record using MDX index file. If there’s no MDX files found, it needs to be force so that the application still can read the DBF files & doing operation within. Here below I create a procedure in order to force to by-passing the need of MDX files:
on E: EDBEngineError do
if Pos('Index does not exist', E.Message) > 0 then
MessageDlg('MDX file not found.Attempting to Open without Index.', mtWarning, [mbOK], 0);
PostMessage(btnProses.Handle, cn_Command, bn_Clicked, 0);
The above procedure will execute twice from the TButton action trigger & forcing nonexistence of MDX file. It’s mean that, after TButton pressed, an error window will show up & try except lines will be executed. Next, DBF reading process will be executed again automatically (PostMessage(btnProses.Handle, cn_Command, bn_Clicked, 0)). Have a great experiment on this!
PS: If you've benefit from this blog,
you can support it by making a small contribution.