Problem with CursorType while Opening Query

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Balaji
Posts: 20
Joined: Thu 05 Oct 2006 04:45

Problem with CursorType while Opening Query

Post by Balaji » Tue 17 Apr 2007 09:58

Hi,

I am facing problem cursor type when i am using SDAC components.

In my Project i have TMainMenu. I have MainMenu item and Five submenu item for the main menu. I have a MainMenu click event. In the menuclick event i have try..finally block. In the "try" block i am opening a query component and based on the dataset values i am changing the captions of the submenu's. In the "Finally" block i am closing the query.

The code in the MenuClick event is as below:
--------------------------------------------------------------------------------
try
Screen.Cursor := crDefault;
MsQuery1.Close;
MsQuery1.Open;
test := Sender As TMenuItem;

for i := 0 to test.Count - 1 do
begin
test.Items.Visible := False;
test.Items.Tag := 0;
end;
i := 0;

while (not MsQuery1.EOF) and (i < 5) do
begin
with test.Items do
begin
Caption := 'Success';
Visible := True;
Tag := 1;
end; { with }

Inc(i);

MsQuery1.Next;
end; {while }

finally
MsQuery1.Close;
Screen.Cursor := crDefault;
end; { try }
--------------------------------------------------------------------------

Now the Problem i have is the cursor is getting changed into crSQLwait state even though i am setting to crDefault before and after the query opening and closing.

Note: I have added sdacvcl to the uses clause of my unit as i need it for other purposes.

Can i know the reason for this and the solution to the same.

I am using SDAC 3.80 licensed version and Delphi 7 Version. Data base Version is SQL Server 2005.

Regards
balajee

Jackson
Posts: 512
Joined: Thu 26 Jan 2006 10:06

Post by Jackson » Tue 17 Apr 2007 11:58

Just set the DBAccess.ChangeCursor variable to False anywhere in your program. The cursor will stop changing.

Balaji
Posts: 20
Joined: Thu 05 Oct 2006 04:45

Post by Balaji » Tue 17 Apr 2007 13:05

Thank you, It Solved My Problem.

Post Reply