Edit dosen't work

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for MySQL in Delphi and C++Builder
Post Reply
nucleide
Posts: 6
Joined: Thu 15 Sep 2005 14:44

Edit dosen't work

Post by nucleide » Wed 05 Apr 2006 14:48

Hello,

Since we install the DBEXpress MySQL, the edit fonction of the ClientDataset don't work.. We can Append a new record to the database but not edit.

I try a lot of combination, including changing field type and nothing seems working. The ReconcileError tell me that the record cannot be found or it might be take by someone else. (but it's not).

here is a little exemple of my code..

procedure TAppareils.DesactiverDB(var LeDataset: TClientDataset);
begin
if not LeDataset.Active then
LeDataset.Active := true;

if LeDataset.Locate('chr_Identificateur', FIdentificateur, Options) then;
begin
LeDataset.Edit;
LeDataset.FieldValues['chr_Actif'] := 'FALSE'; //false
// LeDataset.FieldByName('chr_Actif').AsString := 'FALSE';
// LeDataset.FieldByName('chr_Actif').Value := 'FALSE';
// LeDataset.post;
LeDataset.ApplyUpdates(-1);
end;
end;

My Connection is in 'MySQL Direct (Core Lab)' mode. MySQL version is mysql-4.1.18-win32.

As you can see the code is very simple.. it should work. Did the client dataset is the problem or another dbexpress component? I need help, i'm stuck here!

Thank you very much!
Luc

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Fri 07 Apr 2006 15:14

We have thoroughly tested this problem. It happens when there are records with zero values in DATETIME field in the table. When you edit and post such record without changing DATETIME field value and then call ApplyUpdates, the error is raised. To solve this problem make sure that you have Primary Key in your table and set DataSetProvider.UpdateMode to upWhereKeyOnly.

nucleide
Posts: 6
Joined: Thu 15 Sep 2005 14:44

Edit dbexpress

Post by nucleide » Thu 20 Apr 2006 16:23

hi,

I try your way and nothing append too.

No matter what i done, the edit fuction not work...

The database seems not to be the problem, because i'm able to do it into an SQL query windows...

any other suggestion?

nucleide
Posts: 6
Joined: Thu 15 Sep 2005 14:44

Using ADO

Post by nucleide » Thu 20 Apr 2006 17:27

Hi,

I use almost the same code with ado and it's working perfectly.

nucleide
Posts: 6
Joined: Thu 15 Sep 2005 14:44

Edit ClientDataset finally work but....

Post by nucleide » Thu 20 Apr 2006 19:45

We finaly try a way to get a record update and find where the problem come from.

It seems that the ClientDataset and the Provider connection are break some how. Usualy we use this code with Mysql and MSSQL: The ClientDataset is attached to the Provider.

if CDSAppareils.Locate('CHR_IDENTIFICATEUR' UnAppareil.Identificateur, Options) then;
begin
CDSAppareils.Edit;
CDSAppareils.FieldByName('CHR_ACTIF').VALUE := FALSE;
CDSAppareils.ApplyUpdates(-1);
end;

And everything suppose to be fine.. But this time it dosen't work. Even if we use ConnectionTransaction. and Commit.

but, if we use this code it work :


if CDSAppareils.Locate('CHR_IDENTIFICATEUR', UnAppareil.Identificateur, Options) then;
begin
CDSAppareils.Edit;
CDSAppareils.FieldByName('CHR_ACTIF').VALUE := FALSE;
// CDSAppareils.ApplyUpdates(-1);
DSPAppareils.ApplyUpdates(CDSAppareils.Delta, -1, nCount);
end;

So, did CRLAB will apply a fix soon?

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Fri 21 Apr 2006 14:42

Our driver doesn't "know" what way do you use to apply updates: the first one or the second one. We don't think that the problem concerns our driver because it doesn't generate update queries. Please check if the problem persists using standard driver. If it doesn't, please send us (dbxmda*crlab*com) a complete small sample to demonstrate it, including script to create and fill table.

Also supply us following information
- Exact version of Delphi, C++ Builder or Kylix
- Exact version of dbxMda.
- Exact version of MySQL server.

Post Reply