BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Freeing TAdoQuery causes problem "Cursor Cx not opened"

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi As400
View previous topic :: View next topic  
Author Message
Régis CLUSEAU
Guest





PostPosted: Wed Dec 03, 2003 1:13 pm    Post subject: Freeing TAdoQuery causes problem "Cursor Cx not opened" Reply with quote



Hi,
Strange behavior of DB2/400, when using an AdoQuery created dynamically.

I have a TDBGrid based on a TADOQuery "QryCand".
When doubleclic on a row, I intend to change the value of a column. But
before, doing so, I must ask in another AdoQuery if I am allowed.

procedure TForm1.DBGrid1DblClick(Sender: TObject);
begin
If AmIAllowed Then Begin
Dm.QryCand.Edit; // DM is the DataModule
If Dm.QryCand.FieldByName('Selected').AsBoolean = True Then
Dm.QryCand.FieldByName('Selected').AsBoolean := False
Else
Dm.QryCand.FieldByName('Selected').AsBoolean := True;
Dm.QryCand.Post;
End;
end;

function AmIAllowed : Boolean;
Var
AQry : TAdoQuery;
SqlCmd : String;
Begin
SqlCmd := 'SELECT * FROM TableXX WHERE yyyy ';
AQry := TADOQuery.Create(Nil);
AQry.Connection := AConnection;
AQry .CursorLocation := clUseClient;
AQry .CursorType := ctStatic;
AQry .Prepared := True;
...
AQry.Open;
If AQry.RecordCount > 0 Then
Result := True
Else
Result := False;
AQry.Close;
AQry.Free; // This Free cause a problem later.

End;


After QryCand.Post, I found in the log of the AS400, an error "Cursor Cx not
opened" with high severity.
The Delphi application is still working perfectely.
If "AQry.Free" is removed. I have no error in the log.

Strange isn't it ?

When an ADO query is freed (after a close), it seems, there is a dialog
between DB2 and the dataset.
Who knows ?
What can I do ?

There is the possibility to create the Query like this
TADOQuery.Create(AOwner) and leave the owner destroy the query when the
owner is freed. But the memory will be used for nothing, untill the end.

--
Régis CLUSEAU
[email]r.cluseau (AT) datasoft (DOT) fr[/email]


Back to top
Régis CLUSEAU
Guest





PostPosted: Thu Dec 18, 2003 12:44 pm    Post subject: Re: Freeing TAdoQuery causes problem "Cursor Cx not opened" Reply with quote



I found out that the same problem appears on Visual Basic similar program.

Régis CLUSEAU

"Régis CLUSEAU" <r.cluseau (AT) datasoft (DOT) fr> a écrit dans le message news:
3fcde18d$2 (AT) newsgroups (DOT) borland.com...
Quote:
Hi,
Strange behavior of DB2/400, when using an AdoQuery created dynamically.

I have a TDBGrid based on a TADOQuery "QryCand".
When doubleclic on a row, I intend to change the value of a column. But
before, doing so, I must ask in another AdoQuery if I am allowed.

procedure TForm1.DBGrid1DblClick(Sender: TObject);
begin
If AmIAllowed Then Begin
Dm.QryCand.Edit; // DM is the DataModule
If Dm.QryCand.FieldByName('Selected').AsBoolean = True Then
Dm.QryCand.FieldByName('Selected').AsBoolean := False
Else
Dm.QryCand.FieldByName('Selected').AsBoolean := True;
Dm.QryCand.Post;
End;
end;

function AmIAllowed : Boolean;
Var
AQry : TAdoQuery;
SqlCmd : String;
Begin
SqlCmd := 'SELECT * FROM TableXX WHERE yyyy ';
AQry := TADOQuery.Create(Nil);
AQry.Connection := AConnection;
AQry .CursorLocation := clUseClient;
AQry .CursorType := ctStatic;
AQry .Prepared := True;
...
AQry.Open;
If AQry.RecordCount > 0 Then
Result := True
Else
Result := False;
AQry.Close;
AQry.Free; // This Free cause a problem later.

End;


After QryCand.Post, I found in the log of the AS400, an error "Cursor Cx
not
opened" with high severity.
The Delphi application is still working perfectely.
If "AQry.Free" is removed. I have no error in the log.

Strange isn't it ?

When an ADO query is freed (after a close), it seems, there is a dialog
between DB2 and the dataset.
Who knows ?
What can I do ?

There is the possibility to create the Query like this
TADOQuery.Create(AOwner) and leave the owner destroy the query when the
owner is freed. But the memory will be used for nothing, untill the end.

--
Régis CLUSEAU
[email]r.cluseau (AT) datasoft (DOT) fr[/email]





Back to top
Mark Smits
Guest





PostPosted: Thu Dec 18, 2003 1:56 pm    Post subject: Re: Freeing TAdoQuery causes problem "Cursor Cx not opened" Reply with quote



Are you using the Client Access ADO drivers ?

If yes, you may want to try turning on tracing, which will write some
logfiles. From a dos box enter the command cwbzztrc with no parameters
to see all possible options.

I always use the +a parameter. Don't forget to turn it off after you
are done. If you specify no filename with the -tf or -lf parameter the
files are usually written in the folder "My documentsIBMClient
AccessServiceTrace Files".

There is a lot of "garbage" in the tracefiles, that will not help you,
but you might find some clues. For example, you will find the complete
SQL that is sent to the AS400 when you use Post.

And you might see what communications there might be when freeing the
object.

Hope it helps.

Kind regards,
Mark Smits
--


Com-Unit BV, The Netherlands.
The makers of Spider-Road®.

On Thu, 18 Dec 2003 13:44:59 +0100, "Régis CLUSEAU"
<r.cluseau (AT) datasoft (DOT) fr> wrote:

Quote:
I found out that the same problem appears on Visual Basic similar program.

Régis CLUSEAU

"Régis CLUSEAU" <r.cluseau (AT) datasoft (DOT) fr> a écrit dans le message news:
3fcde18d$2 (AT) newsgroups (DOT) borland.com...
Hi,
Strange behavior of DB2/400, when using an AdoQuery created dynamically.

I have a TDBGrid based on a TADOQuery "QryCand".
When doubleclic on a row, I intend to change the value of a column. But
before, doing so, I must ask in another AdoQuery if I am allowed.

procedure TForm1.DBGrid1DblClick(Sender: TObject);
begin
If AmIAllowed Then Begin
Dm.QryCand.Edit; // DM is the DataModule
If Dm.QryCand.FieldByName('Selected').AsBoolean = True Then
Dm.QryCand.FieldByName('Selected').AsBoolean := False
Else
Dm.QryCand.FieldByName('Selected').AsBoolean := True;
Dm.QryCand.Post;
End;
end;

function AmIAllowed : Boolean;
Var
AQry : TAdoQuery;
SqlCmd : String;
Begin
SqlCmd := 'SELECT * FROM TableXX WHERE yyyy ';
AQry := TADOQuery.Create(Nil);
AQry.Connection := AConnection;
AQry .CursorLocation := clUseClient;
AQry .CursorType := ctStatic;
AQry .Prepared := True;
...
AQry.Open;
If AQry.RecordCount > 0 Then
Result := True
Else
Result := False;
AQry.Close;
AQry.Free; // This Free cause a problem later.

End;


After QryCand.Post, I found in the log of the AS400, an error "Cursor Cx
not
opened" with high severity.
The Delphi application is still working perfectely.
If "AQry.Free" is removed. I have no error in the log.

Strange isn't it ?

When an ADO query is freed (after a close), it seems, there is a dialog
between DB2 and the dataset.
Who knows ?
What can I do ?

There is the possibility to create the Query like this
TADOQuery.Create(AOwner) and leave the owner destroy the query when the
owner is freed. But the memory will be used for nothing, untill the end.

--
Régis CLUSEAU
[email]r.cluseau (AT) datasoft (DOT) fr[/email]





Back to top
Régis CLUSEAU
Guest





PostPosted: Tue Dec 30, 2003 8:48 am    Post subject: Re: Freeing TAdoQuery causes problem "Cursor Cx not opened" Reply with quote

Hi,

In fact I have already used cwbzztrc log. But it does not help very much.
I have also used the IBM SQL performance monitor in order to visualise the
commands reaching DB2.
I discovered that the problem is the same in Visual Basic.
I am sure now that the problem is a bug on IBM side.
Thank-you for helping.

Régis CLUSEAU


"Mark Smits" <Smitsxxx (AT) xxxCom-Unit (DOT) com> a écrit dans le message news:
[email]5qb3uvcsn8p8qhmhfgnl9lde7oqq7b5i83 (AT) 4ax (DOT) com[/email]...
Quote:
Are you using the Client Access ADO drivers ?

If yes, you may want to try turning on tracing, which will write some
logfiles. From a dos box enter the command cwbzztrc with no parameters
to see all possible options.

I always use the +a parameter. Don't forget to turn it off after you
are done. If you specify no filename with the -tf or -lf parameter the
files are usually written in the folder "My documentsIBMClient
AccessServiceTrace Files".

There is a lot of "garbage" in the tracefiles, that will not help you,
but you might find some clues. For example, you will find the complete
SQL that is sent to the AS400 when you use Post.

And you might see what communications there might be when freeing the
object.

Hope it helps.

Kind regards,
Mark Smits
--


Com-Unit BV, The Netherlands.
The makers of Spider-Road®.

On Thu, 18 Dec 2003 13:44:59 +0100, "Régis CLUSEAU"
[email]r.cluseau (AT) datasoft (DOT) fr[/email]> wrote:

I found out that the same problem appears on Visual Basic similar
program.

Régis CLUSEAU

"Régis CLUSEAU" <r.cluseau (AT) datasoft (DOT) fr> a écrit dans le message news:
3fcde18d$2 (AT) newsgroups (DOT) borland.com...
Hi,
Strange behavior of DB2/400, when using an AdoQuery created
dynamically.

I have a TDBGrid based on a TADOQuery "QryCand".
When doubleclic on a row, I intend to change the value of a column. But
before, doing so, I must ask in another AdoQuery if I am allowed.

procedure TForm1.DBGrid1DblClick(Sender: TObject);
begin
If AmIAllowed Then Begin
Dm.QryCand.Edit; // DM is the DataModule
If Dm.QryCand.FieldByName('Selected').AsBoolean = True Then
Dm.QryCand.FieldByName('Selected').AsBoolean := False
Else
Dm.QryCand.FieldByName('Selected').AsBoolean := True;
Dm.QryCand.Post;
End;
end;

function AmIAllowed : Boolean;
Var
AQry : TAdoQuery;
SqlCmd : String;
Begin
SqlCmd := 'SELECT * FROM TableXX WHERE yyyy ';
AQry := TADOQuery.Create(Nil);
AQry.Connection := AConnection;
AQry .CursorLocation := clUseClient;
AQry .CursorType := ctStatic;
AQry .Prepared := True;
...
AQry.Open;
If AQry.RecordCount > 0 Then
Result := True
Else
Result := False;
AQry.Close;
AQry.Free; // This Free cause a problem later.

End;


After QryCand.Post, I found in the log of the AS400, an error "Cursor
Cx
not
opened" with high severity.
The Delphi application is still working perfectely.
If "AQry.Free" is removed. I have no error in the log.

Strange isn't it ?

When an ADO query is freed (after a close), it seems, there is a dialog
between DB2 and the dataset.
Who knows ?
What can I do ?

There is the possibility to create the Query like this
TADOQuery.Create(AOwner) and leave the owner destroy the query when the
owner is freed. But the memory will be used for nothing, untill the
end.

--
Régis CLUSEAU
[email]r.cluseau (AT) datasoft (DOT) fr[/email]







Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi As400 All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.