Maintaining variable data and objects in a MTS object 
Author Message
 Maintaining variable data and objects in a MTS object

Hi!

I'm developing a COM/MTS 3-tier application, i'm new in this technologies,
and i have a big problem for me:

Always loose data stored in variable class after calling method object.

I have an ActiveX DLL project with a class that manage ADODB.connection
create, open and close it, execute SQL commands passing as arguments etc..
And other class, one for table database that contains ADODB.commands with
his SQL Commands, and a reference for Connection manager for execute it.

This structure works fine in a Win32 application and it's clearly for me,
but in
COM architecture i'll have problems.

Every class is a component and CreateObject or CreateInstance method should
be use for create instance classes of  same ActiveX project isn't? Or new
instead.

I'll create a instance from client of a principal component and call a
method that
creates the ConnectionManager Object and  call method to create and open
ADODB.connection. Afther calling it, private variable of class that stores
ADODB.connection is set to nothing.

Succesive methods thats like ExecuteSQLCommand that needs this  connections
causes an error

I'll want to maintain ADODB.Connection variable or Connection String instead
in
this Data Access Layer Component without passing every time a method's
component
is called.

I look for marshaling but I doesn't understand how it's works, also i look
for persistent
component's data but storing object in a file and read every time it's
needed will causes
an overhead.

Any help will be appreciate.
Thanks

--
S2
Luis.



Mon, 11 Oct 2004 19:03:47 GMT  
 Maintaining variable data and objects in a MTS object

Luis,

Are you calling SetComplete at the end of your method calls? If you are then
your COM+ component is being deactivated (effectively destroyed) at the end
of the method call. When you call the next method for that object COM+ will
create a brand new instance of the object for you to use, hence your member
variables will not retain their values. This is why most COM+ components are
designed to be stateless.

To explore this topic further I suggest you check out "Programming
Distributed Applications With Com & Microsoft Visual Basic 6.0" by Ted
Pattison.

--
Rob Windsor
G6 Consulting
Toronto, Canada



Quote:
> Hi!

> I'm developing a COM/MTS 3-tier application, i'm new in this technologies,
> and i have a big problem for me:

> Always loose data stored in variable class after calling method object.

> I have an ActiveX DLL project with a class that manage ADODB.connection
> create, open and close it, execute SQL commands passing as arguments etc..
> And other class, one for table database that contains ADODB.commands with
> his SQL Commands, and a reference for Connection manager for execute it.

> This structure works fine in a Win32 application and it's clearly for me,
> but in
> COM architecture i'll have problems.

> Every class is a component and CreateObject or CreateInstance method
should
> be use for create instance classes of  same ActiveX project isn't? Or new
> instead.

> I'll create a instance from client of a principal component and call a
> method that
> creates the ConnectionManager Object and  call method to create and open
> ADODB.connection. Afther calling it, private variable of class that stores
> ADODB.connection is set to nothing.

> Succesive methods thats like ExecuteSQLCommand that needs this
connections
> causes an error

> I'll want to maintain ADODB.Connection variable or Connection String
instead
> in
> this Data Access Layer Component without passing every time a method's
> component
> is called.

> I look for marshaling but I doesn't understand how it's works, also i look
> for persistent
> component's data but storing object in a file and read every time it's
> needed will causes
> an overhead.

> Any help will be appreciate.
> Thanks

> --
> S2
> Luis.



Mon, 11 Oct 2004 23:19:36 GMT  
 Maintaining variable data and objects in a MTS object
Hi!

Yes I'm callin Set Complet at the end of Method Call.
I thought only deactivate method was called, not terminate.

To avoid passing connection string as parameter every time
a method is called without hard-code implementation.
What about Construct String?

It's posible to access it in a VB COM+ component or needs
to be a poolable object developed in C++?

Thanks a lot

Greetings from Spain
Luis



Wed, 13 Oct 2004 03:44:29 GMT  
 Maintaining variable data and objects in a MTS object
this is exactly why construction strings exist...

--
Joe Long
Microsoft
This posting is provided "AS IS" with no warranties, and confers no rights.


Quote:
> Hi!

> Yes I'm callin Set Complet at the end of Method Call.
> I thought only deactivate method was called, not terminate.

> To avoid passing connection string as parameter every time
> a method is called without hard-code implementation.
> What about Construct String?

> It's posible to access it in a VB COM+ component or needs
> to be a poolable object developed in C++?

> Thanks a lot

> Greetings from Spain
> Luis



Wed, 13 Oct 2004 07:12:55 GMT  
 Maintaining variable data and objects in a MTS object
If you set your connection string in your Class_Initialize, it will stick
around just as if you were using a Construct string. This is because VB COM
components can't be pooled, so Class_Initialize is called every time the
component is activate.

RMD


Quote:
> Hi!

> Yes I'm callin Set Complet at the end of Method Call.
> I thought only deactivate method was called, not terminate.

> To avoid passing connection string as parameter every time
> a method is called without hard-code implementation.
> What about Construct String?

> It's posible to access it in a VB COM+ component or needs
> to be a poolable object developed in C++?

> Thanks a lot

> Greetings from Spain
> Luis



Thu, 14 Oct 2004 11:30:50 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Error: COM+ MTS Object or With Block Variable Not Set

2. Error: COM+ MTS Object or With Block Variable Not Set

3. MTS object in Data Environment

4. Persistent data inside MTS objects

5. MTS and Non MTS objects from same code

6. Setting an object variable to Nothing does not destroy the object

7. object already loaded/ object variable not set HELP???

8. Can Printer Object be assigned to an Object Variable

9. Object Variables and printer objects

10. Need value of object where object name is variable

11. Maintaining formatting while copying objects

12. Collection Object that maintains order of entry?

 

 
Powered by phpBB® Forum Software