Re: How do you create a data access layer?



swansnow wrote:
Maybe this is another newbie question... :)

I've read that you really should have a abstracted data layer, to
decouple database accesses from the rest of your code. I'm not really
sure what this works out to in practice.  Here's a guess:

I'd say make 3 things:

A) a Form with controls
B) an object or record wich contains similar data as
the form, but isn't influcenced by events and stuff
C) procedures (standalone or part of object B) that do
database operations that require or return Bs.

So, A shows, B is cleared.

User enters Street, City and Name and presses "new customer"

The buttonclick transfers Street, City and Name to an
TCustomer Object MyNewCust

Procedure CreateCustomer(MyNewCust) is called and issues an
"insert into customer values MyNewCust.street,MyNewCust.City,
MyNewCust.Name" SQL statement.

Thats how i would do it with manual SQL - no idea how
it could be used with data aware controls :-)

.


Quantcast