#1 2014-03-10 12:17:24

tech
Member
Registered: 2014-01-13
Posts: 110

Exception with FreeAndNil(TOleDBMSSQL2008ConnectionProperties)

Hi,

I got this exception when I try to freeing a TOleDBMSSQL2008ConnectionProperties :

'You should call TOleDBConnection.Free from the same thread which called its Create: i.e. call MyProps.EndCurrentThread from an THttpServerGeneric.OnHttpThreadTerminate event - see ticket 213544b2f5 

I saw the ticket but I don't understand what's wrong.

Thnx.

Offline

#2 2014-03-10 12:22:51

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Exception with FreeAndNil(TOleDBMSSQL2008ConnectionProperties)

How do you create the TOleDBMSSQL2008ConnectionProperties  instance?
How do you free the TOleDBMSSQL2008ConnectionProperties instance?

It should be on the same thread.

If you use interface-based services, ensure you define properly the threading options for the interface, e.g. opt*InPerInterfaceThread in TServiceFactoryServer options.

Offline

#3 2014-03-10 12:29:34

tech
Member
Registered: 2014-01-13
Posts: 110

Re: Exception with FreeAndNil(TOleDBMSSQL2008ConnectionProperties)

aPropsMS := TOleDBMSSQL2008ConnectionProperties.Create('127.0.0.1', 'MSDB', 'sa', '');

and

FreeAndNil(aPropsMS);

All on the same unit.

the create is on the server.create and the freeAndNil on the Server.Destroy.
I don't use the interface-based services.

Last edited by tech (2014-03-10 15:21:19)

Offline

#4 2014-03-10 22:11:40

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Exception with FreeAndNil(TOleDBMSSQL2008ConnectionProperties)

The same unit but not the same thread...

Offline

#5 2014-03-11 09:44:29

tech
Member
Registered: 2014-01-13
Posts: 110

Re: Exception with FreeAndNil(TOleDBMSSQL2008ConnectionProperties)

The server is created/freed on the main form and the TOleDBMSSQL is created/freed on the server.
I think they are on the same thread.

Offline

#6 2014-03-11 14:20:31

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Exception with FreeAndNil(TOleDBMSSQL2008ConnectionProperties)

tech wrote:

I think they are on the same thread.

If you have an exception about "You should call TOleDBConnection.Free from the same thread which called its Create", I suppose suppose this is not the case.
sad

Offline

#7 2014-03-11 17:12:38

tech
Member
Registered: 2014-01-13
Posts: 110

Re: Exception with FreeAndNil(TOleDBMSSQL2008ConnectionProperties)

I've emplemented the Server.HttpServer.OnHttpThreadTerminate notification to call this as indicated :

aPropsMS.EndCurrentThread;

but I got a serious AV
---------------------------
Application Error
---------------------------
Exception EAccessViolation in module project1.exe at 000043B8.

Access violation at address 004043B8 in module 'project1.exe'. Read of address 49776F2E.

---------------------------
OK   
---------------------------

I confess that I have trouble understanding how mORMot works.

Thnx,

Offline

#8 2014-03-12 09:46:18

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Exception with FreeAndNil(TOleDBMSSQL2008ConnectionProperties)

In current unstable 1.18 revision, TSQLRestServerStaticExternal.EndCurrentThread will call automagically TOleDBMSSQL2008ConnectionProperties.EndCurrentThread.
So you are not supposed to call it by hand, when using the integrated ORM feature with external tables.

Offline

#9 2014-03-12 12:04:23

tech
Member
Registered: 2014-01-13
Posts: 110

Re: Exception with FreeAndNil(TOleDBMSSQL2008ConnectionProperties)

Ok, good news.

Thank you ab.

Offline

Board footer

Powered by FluxBB