Re: DataSet Transactions Help

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Yes, this still applies to WIndows Forms with the obvious code changes for
the presentation layer. The idea behind the code sample in the article is
that the user enters a series of inserts, updates and deletes on rows in the
Customers, Orders and Order Details tables. THe code handles the grabbing of
the new Order records' ID fields.

Let me know if you have any questions.


// John Papa
// http://codebetter.com/blogs/john.papa


"Brian Scott" wrote:

> Cool, I will check that out tomorrow when I get a chance.
>
> Does this also apply to Win Forms Datagrid principles?
>
> "John Papa" <JohnPapa@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:812A9826-7217-473B-83B5-746DDA0C8512@xxxxxxxxxxxxxxxx
> > I wrote an article in MSDN Mag a few months ago on how to take a DataSet
> with
> > parent and children DataTables related through key fields. The key fields
> > have IDENTITY attributes, which makes the work a bit more involved, but ti
> > can still be done without using extra procs. Take a look at this article
> > (source code is included) and let me know if you have any questions.
> >
> > http://msdn.microsoft.com/msdnmag/issues/04/05/DataPoints/
> >
> >
> > // John Papa
> > // http://codebetter.com/blogs/john.papa
> >
> > "Brian Scott" wrote:
> >
> > > I currently have a defined Datalayer in a C# application which is filled
> > > with data on startup. All forms in the system bind the to this dataset
> data
> > > source. The datatables within the dataset have various datarelations
> setup
> > > and as most of the table keys are Identity fields I had to write stored
> > > procedures on the server to return the new identity upon insert. This
> > > required creating a new SqlCommand object that points at the stored
> > > procedure and setting the Dataadpter insert command to this.
> > >
> > > The issue is that because I had to write specific stored procedures due
> to
> > > using Identity fields I now get an exception when I dont attach the
> > > transaction to the other Dataadapter commands such as its Read, Delete
> and
> > > Update commands. But these are never set and I thereby get a null
> reference
> > > exception. I do not wish to create these other commands manually, only
> the
> > > insert as I need the identity to come back out of the SQL Server upon
> > > insert.
> > >
> > > How do I implement Transactions on Dataset inserts where the datatable
> > > contains an Identity field?
> > >
> > > Thanks.
> > >
> > >
> > >
>
>
>
.



Relevant Pages

  • RE: DataSet Transactions Help
    ... parent and children DataTables related through key fields. ... The datatables within the dataset have various datarelations setup ... > and as most of the table keys are Identity fields I had to write stored ... > Update commands. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: DataSet Transactions Help
    ... > parent and children DataTables related through key fields. ... >> and as most of the table keys are Identity fields I had to write stored ... >> transaction to the other Dataadapter commands such as its Read, ...
    (microsoft.public.dotnet.framework.adonet)
  • DataSet Transactions Help
    ... and as most of the table keys are Identity fields I had to write stored ... using Identity fields I now get an exception when I dont attach the ... transaction to the other Dataadapter commands such as its Read, ... Update commands. ...
    (microsoft.public.dotnet.framework.adonet)