471,337 Members | 1,448 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

Working with objects that are dependent on a database connection.

Hi all.
I'm migrating a small app from vb6 to vb.net. It basically deals with
invoices. This is the first time I do this kind of migration, from an
existing app to a new one, the new app should be as "object oriented" as
practically possible.

I have several objects that are dependent on a database connection, such as
the Invoice, the InvoiceDetail, a Currency object (mostly used to get real
time foreign currency exchange rate, and convert between currencies), etc.

A few questions:

1) What would be the recommended way of dealing with database persistence of
those objects? For example, before persisting a new invoice I should be able
to do some validiy/consistency checks, and then insert the corresponding
database lines within the context of a transaction. This is particularly
important, I need the Invoice and its corresponding InvoiceDetail to be
created correctly, or not at all. Is there a framework that will do that for

2) How to correctly model that dependency of the objects on the database? I
will probably have only one database connection active for the client, and
all the operations regarding database access should use this one. Passing a
database connection as a parameter seems quite cumbersome (for example
invoice.persist(myDatabaseConnection)) so I guess all abjects should inherit
from some kind of super object, a "Session" object or such, so they all can
use the database connection when they need to. Am I right? Is there a better

3) VB.NET has lots of facilities regarding "connecting" GUI controls
directly to database items. I don't know whether I should use the facilities
it provides, or go on a fully separated layer/oriented architecture, which
is what I'm more accustomed to.

Thanks guys, your help is mostly appreciated.
Jul 21 '05 #1
0 895

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by viviane lima - * - * - | last post: by
6 posts views Thread by charliewest | last post: by
2 posts views Thread by Frédéric Mayot | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.