DLL database access causes another login ! 
Author Message
 DLL database access causes another login !

When I do database access within a .DLL, then the database logs in again
(the login dialog is shown and I have to enter a password).

How can I log into the database only once within the calling EXE without
having to do so again within the called DLL?

I would appreciate any ideas...
Andre



Mon, 08 Feb 1999 03:00:00 GMT  
 DLL database access causes another login !


Quote:

>When I do database access within a .DLL, then the database logs in again
>(the login dialog is shown and I have to enter a password).

>How can I log into the database only once within the calling EXE without
>having to do so again within the called DLL?

>I would appreciate any ideas...

I have the exact same problem, and have tried messing about with the
TSession component. So far this has not produced any useful results.
To avoid entering username and password every time, you can, however,
use a trusted login (if you dbase supports this - MSSql does). This will
not prevent database logins, but life will be a little less annoying :-)

Please mail me, if you find a solution.




Sat, 13 Feb 1999 03:00:00 GMT  
 DLL database access causes another login !

Quote:

>When I do database access within a .DLL, then the database logs in again
>(the login dialog is shown and I have to enter a password).

>How can I log into the database only once within the calling EXE without
>having to do so again within the called DLL?

>I would appreciate any ideas...
>Andre


Hi Andre,
my solution is: explicit TDatabase component and Windows API.

* put a TDatabase component on the form in the DLL
* connect to it every TTable and TQuery component in the form (these components
MUST have the property "Active=FALSE" at design-time)
* create a public variable "MainForm: THandle" in the DLL
* create a custon message number "CM_DatabaseLogin = WM_USER + 100" in the CONST
section of the DLL and EXE
* your EXE form MAY open the login dialog.

* your DLL's entry function look like this:

    procedure EntryPoint(MainFormHandle: THandle);
    var
      Params: PChar;
    begin
       MainForm := MainFormHandle;
       Form1 := TForm1.Create(Application);
       Params := StrAlloc(200);
       StrPCopy(Params, '');
       SendMessage(MainForm, CM_DatabaseLogin, Longint(Params), 0);
       Form1.Database1.Params.Clear;
       if StrLen(Params) > 0 then begin
          Form1.Database1.Params.Add(Params);
       StrDispose(Params);
       Form1.Database1.Params.LoginPrompt := not(StrLen(Params) > 0)
       Form1.Table1.Active := TRUE;
       Form1.ShowModal;
    end;    

* your EXE main form may declare in the protected section

    procedure CMDatabaseLogin(var Messate: TMessage); message CM_DatabaseLogin;

    procedure TMainForm.CMDatabaseLogin(var Messate: TMessage); message
CM_DatabaseLogin;
    var
       Par: string;
    begin
       Par := '';
       for I := 0 to Session.Databases[0].Params.Count - 1 do
          Par := Par + Session.Databases[0].Params[I] + ' ';
       Par := Copy(Par, 1, 200);
       StrPCopy(PChar(Message.LParam), Par);
    end;

* your EXE call then DLL's entry function

      EntryPoint(MainForm.Handle);

N.B.: Every TDatabase in DLLs form MUST have a unique DatabaseName property
inside ALL THE APPLICATION (EXE + DLL)

I'm here if you have problem.
Bye |/
Bye |\ino



Sun, 21 Feb 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Database access in DLL cause multiple login?

2. Newbie question: login screen while trying to get access to MS-Access database

3. Avoiding Login Database Form with Access databases (ODBC) ?

4. False login causes pointer errors on SQL7

5. Database Login with Access Tables

6. Access database login

7. Accessing Username from Database Login Dialog - Delphi 1

8. Accessing USERNAME from Database login Delphi 1

9. Delphi1 via ODB to Access 2.0 databases (login screen problems)

10. RS_RUN causes GPF in RS_SQLIF.DLL at 0004:292E

11. Database access from a DLL

12. Database accessing in DLLs

 

 
Powered by phpBB® Forum Software