Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Update dataset when having a autoinc field
Thu, Dec 3 2015 2:50 PMPermanent Link

Huseyin Aliz

myBiss ApS

Avatar

Hi All,

Can anyone see why following fails:

    Database.StartTransaction;
    try
      with Tasks do
      begin
      Columns['TaskID'].SortDirection:=sdAscending;
      SortCaseInsensitive:=True;
      Sort;
      InitFind;
      Columns['TaskID'].AsInteger:=9;
      if Find(False,True) then
         begin
         Tasks.Update;
         Tasks.Columns['Done'].AsBoolean:=True;
         Tasks.Save;
         end;
      end;
      Database.Commit;
      except
      Database.Rollback;
      raise;
   end;

TaskID in dataset tasks are defined as autoinc in dbisam.
It fails with: Database commit response error (cannot find the row for
updating).
It's version 2.03 B1.

Thanks in advance,

Regards,
Hüseyin A.
Thu, Dec 3 2015 7:24 PMPermanent Link

Richard Harding

Wise Nutrition Coaching

Hi

The primary key is needed to locate the row. So, I suspect it means that:

* a primary key is not defined on the table OR
* the dataset is defined as a query and the base table is not defined OR
* something else

Richard
Thu, Dec 3 2015 9:03 PMPermanent Link

Raul

Team Elevate Team Elevate

On 12/3/2015 2:50 PM, Hüseyin Aliz wrote:
> Can anyone see why following fails:
> TaskID in dataset tasks are defined as autoinc in dbisam.
> It fails with: Database commit response error (cannot find the row for
> updating).
> It's version 2.03 B1.


What Richard said - AutoInc field itself is not enough (it just means
increasing integer).

You also need a primary index.

Sionce it's DBISAM esiest change is to alter table with dbsys and change
the default primary index (one with blank name) to have the "TaskID" as
the indexed field.

Raul
Fri, Dec 4 2015 3:34 AMPermanent Link

Huseyin Aliz

myBiss ApS

Avatar

Raul/Richard,

Thanks both. Altering table and setting taskid as primary key did fix
the problem Smile

Regards,
Hüseyin

Den 04-12-2015 kl. 03:03 skrev Raul:
> On 12/3/2015 2:50 PM, Hüseyin Aliz wrote:
>> Can anyone see why following fails:
>> TaskID in dataset tasks are defined as autoinc in dbisam.
>> It fails with: Database commit response error (cannot find the row for
>> updating).
>> It's version 2.03 B1.
>
>
> What Richard said - AutoInc field itself is not enough (it just means
> increasing integer).
>
> You also need a primary index.
>
> Sionce it's DBISAM esiest change is to alter table with dbsys and
> change the default primary index (one with blank name) to have the
> "TaskID" as the indexed field.
>
> Raul
Image