Exe and Dll Orasession access

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
alicinar
Posts: 13
Joined: Fri 03 Oct 2008 10:06

Exe and Dll Orasession access

Post by alicinar » Fri 25 May 2012 08:12

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

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Exe and Dll Orasession access

Post by AlexP » Fri 25 May 2012 09:37

hello,

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

frmDllForm.OraQuery1.Session.AssignConnect(OraVeri);

alicinar
Posts: 13
Joined: Fri 03 Oct 2008 10:06

Re: Exe and Dll Orasession access

Post by alicinar » Fri 25 May 2012 10:38

Not running code.
My project link.

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

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Exe and Dll Orasession access

Post by AlexP » Fri 25 May 2012 12:06

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

alicinar
Posts: 13
Joined: Fri 03 Oct 2008 10:06

Re: Exe and Dll Orasession access

Post by alicinar » Fri 25 May 2012 13:47

thanks alexp.
I will elaborate.

Post Reply