I don't have time to give you the details, I'll just paste
this from the
docs and you'll have to explore it on your own
An alternative to using an auto incrementing value is to use
the NewGuid
method of a Guid object to generate a GUID, or globally
unique identifier,
on the client computer that can be copied to the server as
each new row is
inserted. The NewGuid method generates a 16-byte binary
value that is
created using an algorithm that provides a high probability
that no value
will be duplicated. In a SQL Server database, a GUID is
stored in a
uniqueidentifier column which SQL Server can automatically
generate using
the Transact-SQL NEWID() function. Using a GUID as a primary
key can
adversely affect performance. SQL Server 2005 introduces
support for the
NEWSEQUENTIALID() function, which generates a sequential
GUID that is not
guaranteed to be globally unique but that can be indexed
more efficiently.
> -----Original Message-----
> From: Discussion forum for developers using Windows
Forms to
> build apps and controls
> [mailto OTNET-WI
NFORMS DISCUSS.DEVELOP.COM] On Behalf Of
> Chris Bordeman
> Sent: Tuesday, November 21, 2006 2:32 PM
> To: DOTNET-WINFORMS DISCUSS.DEVELOP.COM
> Subject: Re: [DOTNET-WINFORMS] updating child records
in a
> DataSet w/ new autoinc values after parent insert?
>
> What does that mean?
>
> -----Original Message-----
> From: Discussion forum for developers using Windows
Forms to
> build apps and controls
> [mailto OTNET-WI
NFORMS DISCUSS.DEVELOP.COM] On Behalf Of Vince P
> Sent: Tuesday, November 21, 2006 2:24 PM
> To: DOTNET-WINFORMS DISCUSS.DEVELOP.COM
> Subject: Re: [DOTNET-WINFORMS] updating child records
in a
> DataSet w/ new autoinc values after parent insert?
>
> Use GUIDs/uniqueidentifier instead.
>
> > -----Original Message-----
> > From: Discussion forum for developers using
Windows Forms to build
> > apps and controls [mailto OTNET-WI
NFORMS DISCUSS.DEVELOP.COM] On
> > Behalf Of Chris Bordeman
> > Sent: Tuesday, November 21, 2006 2:16 PM
> > To: DOTNET-WINFORMS DISCUSS.DEVELOP.COM
> > Subject: Re: [DOTNET-WINFORMS] updating child
records in a
> DataSet w/
> > new autoinc values after parent insert?
> >
> > I was actually looking for something more
generalized.
> >
> > I ended up setting cascading updates and deletions
on the relations.
> > The problem there is that when the parent table is
updated not only
> > does it update the child records, it also sets
their state to
> > 'Modified.'
> > This is a big problem because their state was
initially
> 'Added.' So
> > now when I use the data adapter to update the
child table, I get
> > concurrency errors saying the record could not be
modified. Of
> > course, it was never added to the database!
> >
> > Any ideas?
> >
> > -----Original Message-----
> > From: Discussion forum for developers using
Windows Forms to build
> > apps and controls [mailto OTNET-WI
NFORMS DISCUSS.DEVELOP.COM] On
> > Behalf Of Phil Sayers
> > Sent: Tuesday, November 21, 2006 10:59 AM
> > To: DOTNET-WINFORMS DISCUSS.DEVELOP.COM
> > Subject: Re: [DOTNET-WINFORMS] updating child
records in a
> DataSet w/
> > new autoinc values after parent insert?
> >
> > hook into the dataadapter events...
> > i forget the name. but something like the
"Updated" event is a good
> > spot.
> > in there take the new PK value from the parent
row, and
> update all of
> > it's child rows with the new value.
> > now when the dataadapter starts inserting the
child rows they will
> > have the correct reference to the parent.
> >
> >
> > -----Original Message-----
> > From: Discussion forum for developers using
Windows Forms to build
> > apps and controls [mailto OTNET-WI
NFORMS DISCUSS.DEVELOP.COM]On
> > Behalf Of Chris Bordeman
> > Sent: Tuesday, November 21, 2006 11:43 AM
> > To: DOTNET-WINFORMS DISCUSS.DEVELOP.COM
> > Subject: [DOTNET-WINFORMS] updating child records
in a
> DataSet w/ new
> > autoinc values after parent insert?
> >
> >
> > Hi all. Using Dot Net 2.0.
> >
> > I have a TYPED dataset generated by VS. It
contains a parent and a
> > child table with a relationship set up in the
MSSQL database and
> > showing in the dataset. BOTH tables have new
records that
> need to be
> > added to database.
> >
> > I'm able to retrieve the server's autoinc values
on the
> parent table,
> > but I can't seem to get my data adaper to filter
the new autoinc
> > values down to the foreign key field in the child
table.
> >
> >
> > HOW EXACTLY IS THIS DONE???
> >
> >
> >
> > I'm currently doing 3 things:
> > 1. Added an output parameter to the insert
command to grab the new
> > autoinc value and feed it into my autoinc field.
> > 2. Set insertCommand.UpdatedRowSource =
> UpdateRowSource.Both (figure
> > good idea to grab it all).
> > 3. Appended " SELECT " +
identityColumn.ColumnName + " =
> > SCOPE_IDENTITY()" to the insert command.
> >
> > Does #3 keep the entire column's values from being
fed back to the
> > DataTable row?
> >
> > Do I need to AcceptChanges?
> >
> > What about if the operation fails and the
transaction is
> rolled back,
> > how do I undo changes made to the dataset?
> >
> > THANKS!!!
> >
> > Chris B.
|