Weird crash in 6.6.1 beta.

Forum related to version 6.5.1 (alpha) and 6.6.x (beta) of ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
PhillHS
Fresh Boarder
Fresh Boarder
Posts: 12
Joined: 23.05.2007, 14:11
Location: Coventry, UK

Weird crash in 6.6.1 beta.

Post by PhillHS »

Hi,

Using Zeos 6.6.1beta under Delphi 7, my database is a MySQL 5.x on a SuSE Linux server.

The problem is the following code crashes with a EDatabaseError : "ZEditQuery: dataset is not in edit or insert mode". This only happens about 50% of the time, the other 50% it seems to be fine.

Code: Select all

  WITH TZQuery(OrdersDataModule.OrdersSource.DataSet) DO
  BEGIN;
    Close;	{ Close any pending query }
    SQL.Text:=Format('SELECT * from %s where recno=''%s''',[Defs.ViewEditTable.TableName.Value,InRecordNo]);
    Open;	{ Open query and go into edit mode }
    Edit;
    OrderStatus:=FieldByName('status').AsString;
    PosterName:=FieldByName('netname').AsString;
    CTName:=OrdersDataModule.GetCTNetName(FieldByName('chieftech').AsString);
  END;
The SQL ends up being : SELECT * from orders where recno='129'

The code crashes when executing the Open statement. Before entering this code the query has been used to perform an insert using ExecSQL, which is why the close at the start of the above code.

Can anyone shead any light on this ?

Cheers.

Phill.
User avatar
cipto_kh
Senior Boarder
Senior Boarder
Posts: 83
Joined: 28.09.2005, 11:22
Location: Indonesia
Contact:

Post by cipto_kh »

Hi PhillHS maybe you can try this:

Change in ZAbstractRODataset:

Code: Select all

procedure TZAbstractRODataset.ExecSQL;
begin
  ..............
  if (Statement = nil) or (Statement.GetConnection.IsClosed) then
    Statement := CreateStatement(FSQL.Statements[0].SQL, Properties)
  else
    if (Assigned(Statement)) then
      Statement.ClearParameters;
  ...........
end;

function TZAbstractRODataset.CreateResultSet(const SQL: string;
  MaxRows: Integer): IZResultSet;
begin
  Connection.ShowSQLHourGlass;
  try
    if not Assigned(Statement) then
      Statement := CreateStatement(FSQL.Statements[0].SQL, Properties)
    else
      Statement.ClearParameters;
.................
end;
And then in unit ZDbcStatement:

Code: Select all

function TZAbstractCallableStatement.GetOutParam(
  ParameterIndex: Integer): TZVariant;
begin
  if Assigned(OutParamValues) then
  begin
    Result := OutParamValues[ParameterIndex - 1];
    FLastWasNull := DefVarManager.IsNull(Result);
  end else
  begin
    Result:=NullVariant;
    FLastWasNull:=True;
  end;
end;
If it works then please tell me
PhillHS
Fresh Boarder
Fresh Boarder
Posts: 12
Joined: 23.05.2007, 14:11
Location: Coventry, UK

Post by PhillHS »

Tried that, which alas did not seem to work :(

Further investigation has revealed that the open is infact working, however it was triggering the onclick event of a TDBCheck box, which was attempting to modify one of the other fields and failing.

The things is the Database *SHOULD* be open in read/write mode.

Cheers.

Phill.
User avatar
cipto_kh
Senior Boarder
Senior Boarder
Posts: 83
Joined: 28.09.2005, 11:22
Location: Indonesia
Contact:

Post by cipto_kh »

In the first posting you said "The code crashes when executing the Open statement." But now it's OK, after you put the cange code that I told?

Can you give us the simple project that show this case?
Are you already check the ReadOnly property that should be false?
In your code, after change the value you didn't call the "Post" method.
PhillHS
Fresh Boarder
Fresh Boarder
Posts: 12
Joined: 23.05.2007, 14:11
Location: Coventry, UK

Post by PhillHS »

cipto_kh wrote:In the first posting you said "The code crashes when executing the Open statement." But now it's OK, after you put the cange code that I told?
I have indeed put in your changes, but am not sure if this fixed it, cirtainly
I was still getting the crash after the patches where applied, which would suggest not.
Can you give us the simple project that show this case?
Are you already check the ReadOnly property that should be false?
In your code, after change the value you didn't call the "Post" method.
What seems to be happening is that when the open statement is executed, the record is loaded into my DB aware components, including a TDBCheckBox, which can change it's checked property from false to true, at this point it seems to fire the OnClick event (should this happen ?), which has code to modify another feild if this one is checked. Since the above code has not put the DB into edit mode it seems to crash.

So to me the issue seems to be the OnClick firing when the feild is loaded, I'm not sure if this is normap behavior for this component, it would seem a little unusual if it was.

Ok, looking in the delphi help file for the OnClick event it would seem that this behavior is normal, that when the feild is changed that OnClick fires, I have put code in my handler to detect the database state and only try the edit if it's in dsInsert or dsEdit :-

Code: Select all

    IF ((IsITEquipment.Checked) AND (IsEquipment.DataSource.State IN [dsEdit,dsInsert])) THEN
    BEGIN;
      IsEquipment.DataSource.DataSet.FieldByName(IsEquipment.DataField).AsString:='T';
    END;
This seems to have fixed the problem :)

Cheers.

Phill.
User avatar
cipto_kh
Senior Boarder
Senior Boarder
Posts: 83
Joined: 28.09.2005, 11:22
Location: Indonesia
Contact:

Post by cipto_kh »

OK, then it seem to be your program logic that's wrong.
Post Reply