Updating with Data Adapters

U

Utku Uzundumlu

I am trying to write an N-tier application in dotNET.
The layers that i think about implementing are as follows:

--> Presentation Layer - for UI
--> Business Layer - for business rules and logic
--> Object Layer - for business entities and objects used to model the
system
--> Data Access Layer - for data access abstraction
--> System Framework Layer - for helper class libraries (localization,
security, etc)

Data flow across the layers is like this : the data access layer
retrieves data from a DB (SQL, Oracle, etc) and passes it to the
object layer in DataTables. The object layer converts the incoming
data into business objects and passes them to the business layer. The
business layer receives these objects (such as a PersonelList or a
WorkList which inherits from CollectionBase class). The presentation
layer uses DataGrids to display/edit/delete these lists.

The problem is when going down from presentation layer to the data
access layer, PersonelList is converted(inserted) to a DataTable by
the object layer. At this stage all rows in the dataTable are in Added
state. So if i use a data adapter to update the database in the data
access layer, all rows in the DataTable are re-inserted to the related
table(T_Personel table in this case). But the PersonelList will
contain updates and deletes or may be no change. I think of keeping a
state variable in objects to know if they are inserted/modified... But
i discovered that i can't set the DataRowState of the rows in the
DataTable while i am filling the DataTable with the Personel objects
in the PersonelList.

So, here is the problem: I want to use a DataAdapter instead of doing
all insert,delete,update operations by hand, but i can't reflect the
changes in the PersonelList to a DataTable and DataAdapters don't
update PersonelLists. Now, what should/can i do?

Thank you for your interest, Hope to here good news, g'day.
 
W

W.G. Ryan eMVP

You can call AcceptChanges immediately after the insert if everything
already exists - this will reset the rowstate. Thereafter when you make a
modification to the datatable, it will be reflected as a change and the
rowstate will show accordingly. Will this solve your problem?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top