Page 1 of 1

Exe and Dll Orasession access

Posted: Fri 25 May 2012 08:12
by alicinar
Hi,
Open the connecting in my project.
Using the form in the dll.
How can I orasession to the library project?
Please help!

Exe file project:

Code: Select all

procedure ShowForm;stdcall;external '../../Project1dll.dll' name 'ShowDllForm';
procedure connectionVer(Oracon:TOraSession);stdcall;external '../../Project1dll.dll' name 'ShowDllForm';

procedure TMainFrm.Button1Click(Sender: TObject);
begin
OraSession1.Connect;
connectionVer(OraSession1);
ShowForm;
Dll Project:

Code: Select all

library Project1dll;
uses
  SysUtils,
  Classes,
  Ora,
  DllForm in 'DllForm.pas' {frmDllForm};
var
OraVeri:TOraSession;

  procedure connectionVer(Oracon:TOraSession);
  begin
       OraVeri:=Oracon;
  end;

procedure ShowDllForm;stdcall;
begin
  frmDllForm :=TfrmDllForm.Create(nil);
  frmDllForm.OraQuery1.Session:=OraVeri;
  frmDllForm.OraQuery1.Open;
  frmDllForm.Show;
end;

Exports
    ShowDllForm,
    connection ;

begin

Re: Exe and Dll Orasession access

Posted: Fri 25 May 2012 09:37
by AlexP
hello,

Explicit assignment of ToraSession in dll is incorrect. To assign ToraSession, you should use the AssignConnect method:

frmDllForm.OraQuery1.Session.AssignConnect(OraVeri);

Re: Exe and Dll Orasession access

Posted: Fri 25 May 2012 10:38
by alicinar
Not running code.
My project link.

https://rapidshare.com/files/3115621173/dllform.zip

Re: Exe and Dll Orasession access

Posted: Fri 25 May 2012 12:06
by AlexP
Hello,

In your code, the frmDllForm.OraQuery1.Session property is not initialized and equals nil. Because of this you get na error when attempting to work with this property. Please have a look at the sample demonstrating the correct work with dll in ODAC which is located in the ...\Devart\Devart\Odac for RAD Studio XE2\Demos\Miscellaneous\Dll\ directory

Re: Exe and Dll Orasession access

Posted: Fri 25 May 2012 13:47
by alicinar
thanks alexp.
I will elaborate.