Home DADE

Annoying Login Prompt with IBXSession

edited April 2003 in DADE
Using the user data query on the dataTAB I find that the database logon
prompt is presented to the user the first time they run the query.
I am using an IBXSession on a database that specifies LoginPrompt :=
false with the correct parameters set. Setting Connected := true on that
database does not issue a prompt, only the query from RB does so.
How do I eliminate this login?

This issue was discussed before (see below) and I tried all the suggestions
but nothing works. At runtime I start report building by Report.print, while
the Report contains a DataView and Report, which was already loaded to the
Report Designer at design time. And only the first time after starting the
programm the login prompt is presented. The same at design time after
starting the Delphi IDE and opening the projekt.

All data settings are correct, the connection (a TIBDatabase object) is
established (with LoginPrompt = false), but the prompt annoys anyway.
What can I do?

Thanks in advance,
Kai


ARGUS Forstplanung - Waldinventuren und Forstliche Informationssysteme
Dipl.-Forstwirt Kai Staupendahl
kstaupe@gwdg.de






Check out RBuilder\Demos\4. EndUser Databases\InterBase\2. IB Express

The DatabaseName is stored with the report definition. When the report
loads, there must be a connection component available with that name.
The Designer.DataSettings.Database should also be connection to the same
connection componnet. This value is used by the query tools and is used
when creating new dataviews.

If the report loads and no database with the specified name is found,
then a default connection component will be used - I think this is what
you are encountering - the default connection is displaying the logon
prompt.


see article below.


-------------------------------------------------
Tech Tip: How to modify the DatabaseName stored
with a DADE Query
-------------------------------------------------

Currently when DADE is used to create dataviews,
the DatabaseName is stored as part of the query
definition. (This is consistent with Delphi's
approach to specifying a database connection for
a Query object).

In some cases, you may decide that the
DatabaseName needs to be modified at a later date.

We recommend that the DatabaseName
refer to a TDatabase connection component or to
an Alias to provide flexibility for changing
the connection parameters.

A second way to handle this issue is to implement
some code that specifies a DatabaseName
whenever a template is loaded. This can be accomplished
by using the Report.Template.OnLoadEnd event.


1. Declare an event-handler procedure in the private
section of your form declaration.

type
myForm = class(TForm)
private
procedure ReportTemplateLoadEndEvent(Sender: TObject);
public
end;


2. Use the FormCreate event to assign the event-handler to
the event property.

procedure myForm.FormCreate(Sender: TObject)
begin
Report1.Template.OnLoadEnd := ReportTemplateLoadEndEvent;

end;

3. Add code to the event-handler to specify the database name.


procedure myForm.ReportTemplateLoadEndEvent(Sender: TObject)
var
lSQL: TdaSQL;

begin
if GetSQLObject(Report1, lSQL) then
begin
lSQL.DatabaseName := Designer.DataSettings.DatabaseName;
SetSQLObject(Report, lSQL);
lSQL.Free;

end;

end;


4. Below is a tech tip for extracting the SQL object
from a report. TdaSQL is a class defined in daQClass.pas.

-------------------------------------------------
Tech Tip: How to access the SQL object associated
with a Report created using DADE
-------------------------------------------------

uses
daDatMod;


function GetSQLObject(aReport: TppReport; var aSQL: TdaSQL): Boolean;
var
lDataModule: TdaDataModule;
lDataView: TdaDataView;
begin

aSQL := TdaSQL.Create(nil);

{get the datamodule}
lDataModule := daGetDataModule(aReport);

if (lDataModule <> nil) then
begin
lDataView := lDataModule.DataViews[0];

if (lDataView <> nil) and (lDataView is TdaQueryDataView) then
aSQL.Assign(TdaQueryDataView(lDataView).SQL);

end;

Result := (aSQL <> nil);

end;


procedure SetSQLObject(aReport: TppReport; aSQL: TdaSQL);
var
lDataModule: TdaDataModule;
lDataView: TdaDataView;
begin


{get the datamodule}
lDataModule := daGetDataModule(aReport);

if (lDataModule <> nil) then
begin
lDataView := lDataModule.DataViews[0];

if (lDataView <> nil) and (lDataView is TdaQueryDataView) then
TdaQueryDataView(lDataView).SQL := aSQL;

end;

end;





--
Tech Support mailto:support@digital-metaphors.com
Digital Metaphors http://www.digital-metaphors.com



Comments

  • edited April 2003
    Most likely what is happening is that the dataview that is being loaded in
    the report template is comfigured to connect to a diffenent connection for
    the same database or it is creating a default connection and using that.
    Since the dataview is creating a default connection, you'll get a second
    login screen. Eliminate this by saving the template with the current
    database settings you have set on the designer component. Then reload the
    template and see if the problem persists. To see exactly what is in the
    tempalte for the dataview, save the report template as an ascii text file to
    see what the connection name is that it is trying to use. Maybe you have
    code somewhere that is changing this assignment at runtime when the report
    is loaded- Report.Template.OnLoadEnd event?


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited April 2003
    Hi Jim, thanks for your advice. I checked the event code and the template
    file, but there is nothing wrong.
    Except for the line "object daBDEQueryDataView1: TdaBDEQueryDataView" in the
    template file. Why BDE? this is a IBXSession! Could this be the problem?

    The miracle is, that I get this pompt even at design time with all the
    correct settings, when I preview the report the first time after opening the
    project.

    Kai



  • edited April 2003
    Yes, it should be a TdaIBXQueryDataView object. The dataview must have been
    created with a BDE configuration, so it was creating a default BDE
    connection to the IB database which is why you had the extra login screen.
    You should be able to change this class name in the template using notepad.
    Since it was accessing the same IB database, and the table and field names
    are the same it should work correctly when it is loaded into a TppReport
    after you convert the classname manually.

    --
    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited April 2003
    YES, that works!!! Thank you!
    But why does RB create the wrong DataView object? I checked the data
    settings, and they are definitively correct. Is this a bug? And if so, do
    you see a workaround?

    Kai



  • edited April 2003
    Hi Jim,

    Now I got it: There was a BDE alias with the same name as the database
    object that was choosen in the DataSettings of RB. I gues in this case RB
    just ignores the SessionType and tries to connect to the BDE alias.

    Thank you very much for your help!

    Cheers,
    Kai



This discussion has been closed.