Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

URGENT - Query Designer Via code Hangs (This is a repost of my question that i posted last week)

edited July 2001 in General
Hi

I got the code to run Query Designer via code. It runs smooth until u click
on SQL tab. The application hangs completely. Also, with the help of the
same code I was successful in running Query Wizard but faced the same
problem i.e. it hangs when it reaches the last screen or if you press Finish
button.

Does these Query Designer and Query Wizard have some prerequisites i.e. do
we have to execute some code prior running calling Query Designer and
Wizard?

Again, code example will be appreciated.

Many thanx

--
Imran Uddin
Technical Project Leader
Arc Solutions Pakistan Ltd.
www.arcsolutions.com

Comments

  • edited July 2001
    Here's the code:

    uses
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
    StdCtrls,
    daSQL, daDB, daDBBDE, daQueryDesigner, ppTypes;

    type
    TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    private
    FSQL: TdaSQL;
    FSession: TdaSession;

    procedure ValidateNameEvent(Sender: TObject; const aName: String; var
    aNameValid: Boolean);

    public
    { Public declarations }
    end;

    var
    Form1: TForm1;

    implementation

    {$R *.DFM}
    {$R rbDADE.RES}

    procedure TForm1.Button1Click(Sender: TObject);
    var
    lDialog: TdaQueryDesignerForm;
    begin
    lDialog := TdaQueryDesignerForm.Create(Application);
    lDialog.OnValidateName := ValidateNameEvent;
    lDialog.SQLClass := TdaSQL;
    lDialog.SQL.Assign(FSQL);

    lDialog.Initialize;

    {show form}
    if (lDialog.ShowModal = mrOK) then
    begin
    FSQL.Assign(lDialog.SQL);

    Memo1.Lines := lDialog.SQL.SQLText;
    end;

    lDialog.Free;
    end;

    procedure TForm1.FormCreate(Sender: TObject);
    begin

    FSession := TdaBDESession.Create(Self);

    {set SQL properties}
    FSQL := TdaSQL.Create(Self);

    FSQL.Session := FSession;

    FSQL.AllowSelfJoin := True;
    FSQL.DatabaseName := 'DBDEMOS';
    FSQL.DatabaseType := dtParadox;
    FSQL.SQLType := sqBDELocal;

    end;

    procedure TForm1.FormDestroy(Sender: TObject);
    begin
    FSession.Free;
    FSQL.Free;
    end;

    procedure TForm1.ValidateNameEvent(Sender: TObject; const aName: String; var
    aNameValid: Boolean);
    begin
    aNameValid := True;
    end;

    end.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited August 2001

    Hi Jim Bennett,

    Now there are some problems in Query Wizard as well as Query Designer which
    are left and as listed below under each heading:

    Query Wizard:

    Query Wizard is working fine but on the last page there are three options
    as listed below:


    I want first one labeled [Return to Dataworkspace] option invisible/remove
    and by default Preview Query option is selected and take different actions
    on every option. So please let me know how would I track these things like
    which one option is selected.


    Query Designer:

    Query Designer is working fine and when I select the EditSQL option, it
    allows to change existing SQL and all the other tabs like Select Table as
    well as Fields etc disappear. But when I press finish button after changing
    SQL, it populates Memo Control with the SQL built by the designer rather
    than that one which has been changed manually and if there is an error in
    user's typed SQL then how would I track as well as block him to finish until
    removing bugs in SQL.
    So please let me know how it would be done.

    Code examples would be highly appreciated for each.


    regards,


    Imran Uddin
    Technical Project Leader
    Arc Solutions Pakistan Ltd.
    www.arcsolutions.com



  • edited August 2001
    In DADE, the query wizard's form is a TForm, not a TppForm descendent.
    You're would like to get at the buttons on the form. The button in question
    is created in daQueryWizard.pas in procedure
    TdaWizardFinishPage.CreateControls. TdaWizardFinishPage.Valid is where the
    check is. You could create your own descendent class which overrides these
    two methods and use it instead of the TdaWizardFinishPage class. You'll need
    to change the source in TdaQueryWizardDialog.Initialize so that your new
    class is used to create the finish page. The other option is just to change
    the current source so that the button is invisible or not created at all.

    You'll need to perform the SQL validation logic yourself.


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.