Re: Transactions in ADO.Net 2 strongly-typed datsets.



Glenn,

I recently finished the chapters concerning this portion of my upcoming
ADO.NET 2.0 book, so let me try and answer your question.

ADO.NET 2.0 has a new thing called TableAdapters and that is fairly easy to
understand, just experiment/play with creating a strongly typed dataset -
add a query, table adapter - you will figure it out. I personally don't like
that for one reason - it does not offer me the level of concurrency control
I need. It is vastly improved than 1.1 though, but still in an enterprise
app - it does not allow me to fix and twist the design to my liking :). It
still emphasizes on running it's own queries and completely ignoring my data
layer - so its not perfect - but it's better than what it used to be.

Let me address the more enterprise level - get your hands dirty - have full
control method though - which is what I'd prefer to use, simply because it
allows me to use design patterns and data layers etc.

You have more than one tables, with a relation between them right? You need
to filter out Updated rows, (Modified), Added and deleted rows one by one
and use a data adapter to modify ONLY those rows.

Now the order of execution is important, so if there is a one to many
relationship between Group and Groupmembers, you need to first execute
Inserts on Group, then Updates on Groups, followed by Inserts on
GroupMembers, Updates on Group members, and wrap these up by calling Deletes
on Groupmembers, and Delete on Group Members.

Thus you need to
a) Create dataadapters for particular tables, and specify the
updatecommand./deletecommand/insertcommand on them.
b) Execute the Datadapter.Update(DataRow[]) overload, in which you pass in
rows in a particular rowstate - which can be filtered using the
datatable.select method.

You can make the whole thing transactional by doing a

connection.open
connection.begintransaction
... specify the transaction property to all the IUD commands.
tran.commit
conn.close

Multiple table hierarchical "save" (insert/update/delete) is not trivial,
but not impossible either. Previous data access architectures were even
kludgier in comparison - atleast it works now :)

- Sahil Malik [MVP]
http://codebetter.com/blogs/sahil.malik/




<gwolinsky@xxxxxxxxxxxxxxxx> wrote in message
news:1112630101.283533.243380@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Here's the scenario: I have a custom object that represents a group in
> our law firm. For each group, there are many members of that group.
>
> Now, the group object exposes a property that is a strongly-typed
> datatable of the member records. The UI programmer will add/delete
> records from this datatable as the user adjusts the members of the
> group.
>
> Then, the Update method of the group object will not only update it's
> normal properties (name, description, etc.) but will call the update
> method of the adapter for the datatable to write the changes to the
> members.
>
> My question as a ADO.Net 2 newbie is this: How to I wrap the group
> object changes and the changes written by the update in the datatable
> in the same transaction?
>
> I knew how to do this in ADO.Net 1.x, but the properties exposing the
> insert, update, delete command objects in the datatable are not there.
>
> What am I missing?
>
> Any help would be GREATLY appreciated.
>
> Sincerely,
> Glen Wolinksy
>


.



Relevant Pages

  • Re: SQL Server 2000: Identity columns guaranteed sequential?
    ... Let's say you have an input file or staging table like so: ... as separate members, but have only one address and then link them. ... SQL Server MVP ... INSERT transaction A is assigned 301 ...
    (microsoft.public.sqlserver.server)
  • Re: GUI for access 2002
    ... 1.I execute a command button that loads the form with data from a members ...
    (microsoft.public.access.gettingstarted)
  • Re: SP Permission Inheritance and Table Creation
    ... > a way that limits the user from actually mimicking the application ... role so that you can execute sp_rename. ... CREATE PROC usp_PubStatic_Maintenance ... sysadmin role members or the dbo can execute the procedure. ...
    (microsoft.public.sqlserver.security)
  • Re: Backing out of an Ebay auction when its finished?
    ... In effect this is exactly what has happened in the transaction the OP ... member has paid, the PP member has an address end of story. ... first ever ebay purchase does that make me dodgy? ... unverified Paypal account and are more likely than older members to have ...
    (uk.legal)
  • Re: processadmin role
    ... Members of Processadmin role can only kill a process. ... the processes running in SQL Server, the only management option they have is ... To view the history of job, DBA can assign the execute prev on ...
    (microsoft.public.sqlserver.server)