UniLoader error trapping?

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
kgn
Posts: 2
Joined: Wed 08 Oct 2008 07:54

UniLoader error trapping?

Post by kgn » Fri 31 Jan 2014 00:19

I am having problems trying to get the UniLoader component to work in D7. The Help and Demos are extremely limited.

I can get UniLoader to work importing records into a MSSQL database if the destination table is empty. I cannot do it if there are any records in the table. I do not think it has anything to do with duplicate keys or anything like that. I go to some effort to delete any possible conflicts before I do the Load. The problem is it is hard to tell...there does not seem to be any error trapping at all. This is the crux of my question - how can I error trap UniLoader?

This is what I am doing

Code: Select all

UniLoader1.Connection := Master.iConnectUNI; 
UniLoader1.tablename := xxTablename; 
UniLoader1.CreateColumns; 
UniLoader1.OnPutData := PutColumnData;
I open a UniQuery (qryFastLoad) with the records that I want to import into the destination table. Some 20,000 records in my example. If the destination table is empty, no problems (also very fast! Most impressive).

If there are records in the table, a few records are loaded - then it basically freezes. Nothing happens - the program gets into a loop and the process has to be killed.

This is my Put procedure. There is a Primary key on the fields ID,TILLID.

Code: Select all

procedure TfrmSendToRegisters.PutColumnData(Sender: TDALoader); var
   i: integer;
begin
   i := 0;
   if qryFastLoad.recordcount > 0 then
      begin
         ProgressBar2.MaxValue := qryFastLoad.recordcount;
         while (not qryFastLoad.EOF) do
            begin
               inc(i);
               try
                 ProgressBar2.UserValue := i;                
Sender.PutColumnData('ID', i, qryFastLoad.FieldByName('ITEMID').AsString);
Sender.PutColumnData('TillID', i, qryFastLoad.FieldByName('TILL_NUMBER').AsString);
Sender.PutColumnData('COST', i, qryFastLoad.FieldByName('UNITCOST').AsFloat);
Sender.PutColumnData('SELL', i, qryFastLoad.FieldByName('PRICE1').AsFloat);
Sender.PutColumnData('INSTRUCTIONSID', i, qryFastLoad.FieldByName('INSTRUCTION').AsString);
Sender.PutColumnData('ENABLED', i, qryFastLoad.FieldByName('ENABLED').AsString);
                  qryFastLoad.next;
               except
                  on e: exception do
                     begin
                        showmessage('Put Column Error ' + e.message);
                     end;
               end;
            end;
      end;
end;

kneighbour
Posts: 77
Joined: Wed 08 Oct 2008 04:55

Re: UniLoader error trapping?

Post by kneighbour » Tue 04 Feb 2014 23:20

Fixed it!!!

After some excellent Support from Devart, I finally worked out what the problem was.

The problem was that when I ran a query on my destination table (deleting records, for example), the UniQuery ran just fine - but the UniConnection did not Commit. In fact, it locked the table and would not release it until I closed down the application or I disconnected the UniConnection.

This meant that when I ran the Loader to add new records, it often failed as the records that I had thought were deleted, conflicted with the new Loader records.

The real problem here is that the Loader does not give any real error result - it either works or it does not. And even if it does not (as in my case), it simply locks up the program.

After a few days looking into this - what I finally did to fix the problem was to delete my UniConnection and simply add it again. Fixed. I have been using this Datamodule with the UniConection on it for years. I guess it was corrupt in some way - no idea. But now it all works as expected.

Thanks Devart Support for patience with me in this.

Post Reply