Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 16 total
Thread TEDBQuery.OnProgress buglet
Fri, Jan 18 2008 8:38 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim

Trying to get a handle on what sort of ProgressTimeInterval would be best for me I stuck showmessage(inttostr(PercentDone)); into the onprogress event.

I get

Error 1001 a filter error occured (filter not found)

Seems to be line 6723 (in TEDBDataset.SetActiveFilter)

Using  the same query/tables as last time.

Also a question - are there any statements we shouldn't get progress on eg CREATE TABLE ... WITH DATA?

Roy Lambert
Fri, Jan 18 2008 11:04 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< Trying to get a handle on what sort of ProgressTimeInterval would be best
for me I stuck showmessage(inttostr(PercentDone)); into the onprogress
event.

I get

Error 1001 a filter error occured (filter not found)

Seems to be line 6723 (in TEDBDataset.SetActiveFilter)

Using the same query/tables as last time. >>

Are you talking about the CREATE TABLE AS statement again ?  I've got that
in our tests, and it's running fine here with no errors.

--
Tim Young
Elevate Software
www.elevatesoft.com

Fri, Jan 18 2008 11:37 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim


That's the beast. I have an OnProgress event

procedure TDoSQLForm.SwapProgress(Sender: TObject; PercentDone: Integer; var Continue: Boolean);
begin
Progress.Position := PercentDone;
Update;
end;

when I altered it to

procedure TDoSQLForm.SwapProgress(Sender: TObject; PercentDone: Integer; var Continue: Boolean);
begin
Progress.Position := PercentDone;
Update;
showmessage(inttostr(PercentDone));
end;

I get the error otherwise no.

Roy Lambert
Sat, Jan 19 2008 12:32 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< when I altered it to

procedure TDoSQLForm.SwapProgress(Sender: TObject; PercentDone: Integer;
var Continue: Boolean);
begin
Progress.Position := PercentDone;
Update;
showmessage(inttostr(PercentDone));
end;

I get the error otherwise no. >>

Are you setting/clearing a filter in response to any data-aware events ?
It sounds like the processing of the Windows messages is causing a grid,
etc. to try to move the row pointer and fire off some other actions in a way
that is causing the issue.

--
Tim Young
Elevate Software
www.elevatesoft.com

Sat, Jan 19 2008 1:16 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim

>Are you setting/clearing a filter in response to any data-aware events ?
>It sounds like the processing of the Windows messages is causing a grid,
>etc. to try to move the row pointer and fire off some other actions in a way
>that is causing the issue.

Don't think so, can't spot anywhere. Remember its creating a memory table which is linked to the TEDBTable Project. It gets created like this

 Project.Close;
 Project.Filtered := False;
 Project.Filter := '';
 project.DisableControls; <<<<<<<<<<<<< Just added to test
 dsproject.DataSet:=nil; <<<<<<<<<<<<<< ditto
 ZapInMemoryTable(Project,False);
 slFetchProject.Text := StringReplace(CallsQuery.Items.Text, ':ProjectID', IntToStr(ProjectCode), [rfReplaceAll, rfIgnoreCase]);
 slFetchProject.Text := StringReplace(slFetchProject.Text, '$From', dm.DB.Database, [rfReplaceAll]);
 _DoSQLForm(dm.Memory, slFetchProject, 'Opening project: ' + ProjectName);

There was an OnAfterScroll event but I've tried deleting that with no success. Turn off notify on language exceptions and I get a nice cascade of error boxes which makes it look as though it is every row.

Any suggestions as to anything else I can disable to check things out? Ultimately I don't care beacuse taking the showmessage out resolves the problem but I hate these annoyances.

Roy Lambert


and the other bits are

procedure ZapInMemoryTable(WhichTable: TEDBTable; ZapComponent: boolean = True);
var
Zapper: TEDBQuery;
begin
try
 Zapper := TEDBQuery.Create(nil);
 try
  if Assigned(WhichTable) and DoesTableExist(WhichTable) then begin
   WhichTable.DisableControls;
   WhichTable.Close;
   WhichTable.Exclusive := True;
   Zapper.SessionName := WhichTable.SessionName;
   Zapper.DatabaseName := WhichTable.DatabaseName;
   Zapper.SQL.Text := 'DROP TABLE ' + WhichTable.TableName;
   Zapper.ExecSQL;
   Zapper.Close;
   if ZapComponent then FreeAndNil(WhichTable);
  end;
 except
//  MessageDlg('Problem experienced deleteing memory table: ' + #13 + WhichTable.Name + #13 + WhichTable.TableName, mtError, [mbOK], 0);
 end;
finally
 Zapper.Free;
end;
end;

----------------------------------------------------------------------------------------------------------------------------

procedure _DoSQLForm(UseDB:TEDBDatabase; sl: TStrings; Bumph: string; AutoClose: boolean = False);
var
WindowList: Pointer;
Cntr:integer;
begin
 for Cntr := sl.Count - 1 downto 0 do begin
  if Trim(sl[Cntr]) = '' then sl.Delete(Cntr);
 end;
 if sl.Count > 0 then begin
 end;
Application.CreateForm(TDoSQLForm, DoSQLForm);
DoSQLForm.BorderStyle := bsNone;
WindowList := DisableTaskWindows(DoSQLForm.Handle);
try
 DoSQLForm.Progress.Format := Bumph + '...[%d%%]';
 DoSQLForm.Swap.SessionName := UseDB.SessionName;
 DoSQLForm.Swap.DatabaseName := UseDB.DatabaseName;
 DoSQLForm.CloseOnFinish := AutoClose;
 DoSQLForm.Show;
 DoSQLForm.DoTheJob(sl.Text);
finally
 EnableTaskWindows(WindowList);
 DoSQLForm.Release;
end;
end;

----------------------------------------------------------------------------------------------------------------------------

unit DoSQL;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Gauges, DB, ExtCtrls, AdvProgressBar, edbcomps, HHCmnVars;

type
TDoSQLForm = class(TForm)
 Progress: TAdvProgressBar;
 Swap: TEDBQuery;
 procedure FormCreate(Sender: TObject);
 procedure SwapProgress(Sender: TObject; PercentDone: Integer;var Continue: Boolean);
private
   { Private declarations }
public
   { Public declarations }
 CloseOnFinish: boolean;
 procedure DoTheJob(const Script: string);
end;

var
DoSQLForm: TDoSQLForm;

implementation

uses nlhEDB, NLHRoutines;

{$R *.dfm}

procedure TDoSQLForm.DoTheJob(const Script: string);
var
Cntr: integer;
DropTable: string;
SQLChunk: string;
AllSQL: string;
begin
//Engine.SessionList[Swap.SessionName].ProgressTimeInterval := 100;
Screen.Cursor := crSQLWait;
try
 Update;
 Swap.Close;
 Swap.SQL.Clear;
 Cntr := 1;
 SQLChunk := SubFld(Script, ';', Cntr);
 while Trim(SQLChunk) <> '' do begin
  Swap.SQL.Text := SQLChunk;
  if UpperCase(Copy(Swap.SQL.Text, 1, 10)) = 'DROP TABLE' then begin
   DropTable := Copy(Swap.SQL.Text, 12, Maxint);
   if DropTable[Length(DropTable)] = ';' then Delete(DropTable, Length(DropTable), 1);
   DropTable := StringReplace(DropTable, '"', '', [rfReplaceAll]);
   if 0 = Pos('.', DropTable) then begin
    if IsTableThere(Swap.SessionName, Swap.DatabaseName, DropTable) then Swap.ExecSQL;
   end else begin
    if IsTableThere(Swap.SessionName, SubFld(DropTable, '.', 1), SubFld(DropTable, '.', 2)) then Swap.ExecSQL;
   end;
  end else Swap.ExecSQL;
  Swap.Close;
  Swap.SQL.Clear;
  Progress.Position := 0;
  inc(Cntr);
  SQLChunk := SubFld(Script, ';', Cntr);
 end;
// end;
 if CloseOnFinish then Swap.Close;
finally
 Screen.Cursor := crDefault;
end;
end;

procedure TDoSQLForm.SwapProgress(Sender: TObject; PercentDone: Integer; var Continue: Boolean);
begin
Progress.Position := PercentDone;
Update;
showmessage(inttostr(PercentDone));
end;

procedure TDoSQLForm.FormCreate(Sender: TObject);
begin
CloseOnFinish := False;
end;

end.


Sat, Jan 19 2008 2:32 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< Any suggestions as to anything else I can disable to check things out?
Ultimately I don't care beacuse taking the showmessage out resolves the
problem but I hate these annoyances. >>

Well, the easiest way to get to the root of the issue is to try it in a
blank project with nothing else but the statement execution and the
ShowMessage in the OnProgress.  If it works, then you at least know where
you can start adding things to see what can cause the error.

--
Tim Young
Elevate Software
www.elevatesoft.com

Sun, Jan 20 2008 9:14 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim

>Well, the easiest way to get to the root of the issue is to try it in a
>blank project with nothing else but the statement execution and the
>ShowMessage in the OnProgress.

That bit no problem

>If it works, then you at least know where
>you can start adding things to see what can cause the error.

Adding bits back might be a bit more difficult in any simple time efficient manner - I'll just have to hope it blows up with step 1 Smiley

Roy Lambert
Sun, Jan 20 2008 10:58 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim


I have now reached the WTF stage of debugging. I created a blank form in the app. Dropped a couple of TEDBQuery components and a standard TProgressBar on it. Plonked the sql into one of the query components (Holder), used the second (Runner) to run the altered sql. Linked up the OnProgress event and sure enough I get the error.

That's about as isolated as I can get in the app. Oh yeah I ran it with only the main form of the app loaded - no other forms. I also took out all but the table creating bit of the code, all table dropping and index creation gone.

I then copied the unit out into a brand new project, dropped engine and session component on and guess what - no problem.

Just to see I added an OnStatusMessage in. In the real app it blows up faster, in the test app I get the status message.

In the test app it goes:
creating table
table created
percentage done 0
percentage done 100

In the real app it goes: creating table overlaid by percent done 0 and explode

Setting break points in the two events it stops in the onstatusmessage, but when I press F9 rather than waiting for me to click on the showmessage box it just continues and goes into the onprogess event.

I'VE FOUND THE LINK. If I create a separate session I don't get the problem. So shared TEDBSession on a data module = kerblowie!

That's about as far as I can go until the all knowing one comes up with a suggestion.

Roy Lambert
Mon, Jan 21 2008 7:57 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< I'VE FOUND THE LINK. If I create a separate session I don't get the
problem. So shared TEDBSession on a data module = kerblowie! >>

Shared how ?  Do you mean shared by the query and other table components
that may be hooked up to data-aware controls ?

Can you send me the app that blows up ?

--
Tim Young
Elevate Software
www.elevatesoft.com

Mon, Jan 21 2008 8:23 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim

>Shared how ? Do you mean shared by the query and other table components
>that may be hooked up to data-aware controls ?

The main thread has a single session (2 databases, one for disk and one for memory). so yes.

>Can you send me the app that blows up ?

Willingly, but it contains loads of TMS components, a wodge of homebrew ones and a few others. If its of use I'll zip it up and send it.

Or do you just want the exe? Is that what you mean?

Roy Lambert
Page 1 of 2Next Page »
Jump to Page:  1 2
Image