TLiteTable Post Error - Update failed Found 0 records

Discussion of open issues, suggestions and bugs regarding LiteDAC (SQLite Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Bob Boyd
Posts: 14
Joined: Thu 28 Jul 2016 19:26

TLiteTable Post Error - Update failed Found 0 records

Post by Bob Boyd » Thu 28 Jul 2016 20:00

I'm using the evaluation installation of the LiteDAC components in RAD Studio 10.1 Berlin to convert a BDE legacy application that used the InfoPower TwwTable with the TLiteTable component. I've been able to open the connection to the SQLite database and connect TLiteTable objects to the TwwDataSource components that feed the TwwDBGrid to list table records and even apply different sort orders. My first attempt to edit a TLiteTable in a start up utility procedure that must assign a new value to the License table record failed on the Post call generating an EDatabaseError Exception indicating Update failed Found 0 records after the RecordCount property returned > 0. I've found examples of using the TLiteTable Edit, FieldByName and Post calls so I don't understand what I'm doing wrong. I'm hoping the LiteDAC components will be a direct substitution migration path for the application. Any help or suggestions would be appreciated!

The utility procedure code:

Code: Select all

  WC5NewLite := TLiteConnection.Create(Application);
  try
    With WC5NewLite do
    begin
      Database := stTgtDBFile;
      Options.ForceCreateDatabase := False;
      Options.Direct := True;
      Options.DateFormat := 'mm-dd-yyyy';
      LoginPrompt := False; 
      Connect;
      lgRtn := True;
    end;
  except
    lgRtn := False;
    Screen.Cursor := crDefault;
    Application.ProcessMessages;
    MessageDlg('Cannot open a source LiteDAC connection to the SQL database',mtError,[mbOk],0);
  end;
  if lgRtn then
  begin
    OpenLiteSQLDB(WC5NewLite, stTgtDBFile);
    tblTgt := TLiteTable.Create(Application);
    With tblTgt do
    begin
      Connection := WC5NewLite;
      TableName := 'License';
      Open;
      if RecordCount > 0 then
      begin
        Edit;                              // Reassign license for setup
        FieldByName ('License').AsString := 'Setup';
        Post;   <<< Exception occurs
      end else
FWIW, I tried changing the 'License' string for the TableName property to '"License"' thinking there might be a problem with the field name being the same as the table name but that generated an error indicating the field did not exist whereas the correct field name executed correctly before the Post error. How can I access the field but then get an error about 0 records?

MaximG
Devart Team
Posts: 1025
Joined: Mon 06 Jul 2015 11:34

Re: TLiteTable Post Error - Update failed Found 0 records

Post by MaximG » Fri 29 Jul 2016 10:38

We have checked the behavior of LiteDAC 2.7.24 in RAD Studio 10.1 Berlin . Unfortunately, we couldn't reproduce the described behavior. To investigate the issue, please compose a small sample (not using third-party components, including only LiteDAC), that would demonstrate the problem, and send it to maximg*devart*com.

Bob Boyd
Posts: 14
Joined: Thu 28 Jul 2016 19:26

Re: TLiteTable Post Error - Update failed Found 0 records

Post by Bob Boyd » Fri 29 Jul 2016 14:49

Thanks for the reply! I created a test application as suggested and was still able to reproduce my error editing the License table. I switched to the Rx sample fddemo.sdb file and was finally able to Post to the Employees table. I tried another table in my application database and was also able to post records so the problem must be with my source table. Unfortunately, I encountered a new access violation error in the RemoveMediumFreeBlock procedure of GetMem.Inc when the form closes and the TLiteConnect is closed. I sent you an email with my test project to see if you can reproduce this new error.

Regards,
Bob

MaximG
Devart Team
Posts: 1025
Joined: Mon 06 Jul 2015 11:34

Re: TLiteTable Post Error - Update failed Found 0 records

Post by MaximG » Mon 01 Aug 2016 11:30

We have received your project and checked its functioning in RAD Studio 10.1 Berlin . Unfortunately, we couldn't reproduce the error you described, that occurs on the LiteDACTest application closing. In the project, the LastName field value of the Employees table is changed correctly, and the application closes without any errors. Perhaps, the problem is observed when using the License table, that you wrote about earlier. However, the table is absent in fddemo.sdb database. Maybe, to reproduce the issue, another sample or another SQLite DB file with the License table is needed ?

Bob Boyd
Posts: 14
Joined: Thu 28 Jul 2016 19:26

Re: TLiteTable Post Error - Update failed Found 0 records

Post by Bob Boyd » Tue 09 Aug 2016 17:09

Thanks for trying to reproduce the problem. The application database can not be transferred however I found that setting the Options.StrictUpdate = False for the table property suppressed the errors. I have finally made significant progress using the TLiteTable component as a replacement. I found that I have to replacing the IndexName property assignments with a combination of IndexFieldNames and SetOrderBy which is a bit challenging but the records are in the grids!

MaximG
Devart Team
Posts: 1025
Joined: Mon 06 Jul 2015 11:34

Re: TLiteTable Post Error - Update failed Found 0 records

Post by MaximG » Wed 10 Aug 2016 11:35

We are glad you have localized the problem. Please contact us concerning LiteDAC usage.

Post Reply