TUniConnection in DLL when called from web service

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
arusoft
Posts: 45
Joined: Thu 06 Sep 2012 20:19

TUniConnection in DLL when called from web service

Post by arusoft » Thu 07 Feb 2013 06:37

I wanted to create a DLL in delphi that will be called by a C# web service.

This DLL has some database routines like getting info, saving info etc.

I know that DLL has problems if we use global variables. So my plan is to create uniConnection component within a procedure in DLL and then pass along to other procedures as required or is there better way to handle uniConnection in this scenario.

Thank You.

CristianP
Posts: 79
Joined: Fri 07 Dec 2012 07:44
Location: Timișoara, Romania

Re: TUniConnection in DLL when called from web service

Post by CristianP » Thu 07 Feb 2013 07:45

Hi,

It is clear you will need a login() and logout() functions.
The login() can create the uniConnection and return a pointer that you can use in all functions including logout() for freeing.

But a better way is login() to return a handle. This handle will be into a list of sessions with thread-safe accesses.

Best Regards,
Cristian Peţa

arusoft
Posts: 45
Joined: Thu 06 Sep 2012 20:19

Re: TUniConnection in DLL when called from web service

Post by arusoft » Fri 08 Feb 2013 05:47

Thanks for reply. Can you show an example please?

Thanks.

CristianP
Posts: 79
Joined: Fri 07 Dec 2012 07:44
Location: Timișoara, Romania

Re: TUniConnection in DLL when called from web service

Post by CristianP » Fri 08 Feb 2013 11:58

Hi,

You can just use the simple way

Code: Select all

interface
function Connect(out DataModule: Pointer): Boolean; stdcall;
procedure DoSomething(DataModule: Pointer); stdcall;
procedure Disconnect(DataModule: Pointer); stdcall;

implementation

function Connect(out DataModule: Pointer): Boolean; stdcall;
begin
  DataModule := TDataModule1.Create(nil);
  Result := TDataModule1(DataModule).MyConnect;
end;

procedure DoSomething(DataModule: Pointer); stdcall;
begin
  TDataModule1(DataModule).UniQuery1.Open;
end;

procedure Disconnect(DataModule: Pointer); stdcall;
begin
  TDataModule1(DataModule).Free;
end;
Best Regards,
Cristian Peţa

DemetrionQ
Devart Team
Posts: 271
Joined: Wed 23 Jan 2013 11:21

Re: TUniConnection in DLL when called from web service

Post by DemetrionQ » Mon 18 Feb 2013 11:08

Hello.

Please specify whether you have already got a C# library with web service and you want to use DLL from it for work with UniDAC, or you want to create a new DLL web service.
Also note that there is a product for C# similar to UniDAC. You can find more information at http://www.devart.com/dotconnect/universal .

Post Reply