Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ATL Components for Database Access

2 views
Skip to first unread message

Matt

unread,
Mar 31, 2003, 2:46:04 PM3/31/03
to
It was recommended to me (by my boss) that using ATL Components for Database
Access would be more efficient for our application design because it would
allow a majority of the code to easily be ported from one platform to
another, (ie ASP, with a VB App to follow, and an MMC snap-in following
that). So I am in the process of writing database "objects" in C++ that
have the field's values as properties, and Insert, Update, Delete, as
methods (as well as some business logic). My question is this: Is this an
efficient (meaning efficient processor usage and efficient use of manpower
to code) way to develop?

Also, several of the objects have aggregate objects that correspond to
relationships in the database. In the process of doing an insert, a row must
be inserted into each table, to enforce referential integrity. However in
an attempt to use transactions at the database level, I have to ensure that
all the objects within a thread use the same OLEDB datasource and session.
I am not sure how to accomplish this. It was my thought that a pointer to
the session could be passed as a constructor to the objects classes, but I
have been unable to make this work. Any suggestions on this matter would be
appreciated.

Thanks in advance.


George Ter-Saakov

unread,
Mar 31, 2003, 3:47:21 PM3/31/03
to
MTS or COM+ is designed to help you with transactions.

So each object can create it's own database connection and they all are
going to be as part of one big transaction. Even if they are using
different databases.

So for you it becomes transparent and you do not need to worry about
transactions anymore.

As for Object oriented approach versus "normal approach". From my experience
you should always combine both.

For pure business transaction have a object with corresponding method. Like
Account with Withdraw, Deposit, Balance.

For report operations go directly to database or sometimes it's better to
create separate datawarehouse.

George.


"Matt" <sad...@yahoo.com> wrote in message
news:0W0ia.54742$j8.16...@twister.tampabay.rr.com...

Matt

unread,
Mar 31, 2003, 10:26:37 PM3/31/03
to
MTS or COM+ transactions will have the same effect as a database transaction
such as one in SQL Server? I was aware that MTS supported transactions, but
am not real familiar with it. Thanks for the advice on the database
"objects." I will attempt to use a hybrid where possible. That sounds like a
viable solution.


George Ter-Saakov

unread,
Apr 1, 2003, 9:09:23 AM4/1/03
to
Yes.
Actually you need DTS (Distributed Transaction Service) service. But MTS
hides complexity of the DTS with declarative transaction style.
Basically you can specify that "whenever this method called you want to
start transaction". After that all your database connections (you must use
OLE DB) will participate in that transaction. When the method is finished
all objects which were participating in that call vote if transaction should
be committed or rolled back. If one votes negative MTS roles back
transaction.

That's a main reason MTS(COM+) is created. To allow your objects participate
in one transaction. Also since OLE DB connections are pooled in MTS
environment you do not incur any performance problem by opening and closing
connection as often as you need.


Example:
Account_Deposit(lAmount)
{
Con.Open(..)
....
Con.Close(...)
Call AnotherObject_AnohterMethod()
SetMyTransactionVote(TxCommit )
}

AnotherObject_AnotherMethod()
{
Con.Open()
...
Con.Close()
SetMyTransactionVote(TxCommit )
}

In this example Deposit did it's job and then called another business
object. Both objects made modification to database. After return from method
Account_Deposit. COM+ checks if all objects voted for transaction to commit
and commits transaction. (Even if those two connections are made to
different databases it will work).

Yes it works the same way as a database transactions. (Actually MTS only
manipulates them). Only MTS sets transaction Level to SERIALIZABLE ( not
sure that you can change it).

If you are using MS SQL then you should not have any problem. I know couple
of years ago people with Oracle were struggling but could make it work. Do
not know about other databases.


George.

"Matt" <sad...@yahoo.com> wrote in message

news:NF7ia.55532$j8.16...@twister.tampabay.rr.com...

0 new messages