.NET: Why do we need to handle the RowUpdated event of our DataAdapter in order to reflect the ID in a Primary/Foriegn key relationship??

Why do we need to handle the RowUpdated event of our DataAdapter in order to reflect the ID in a Primary/Foreign key relationship?? Well, anyway here is a page that tells you how to do this.

AddHandler daChargeAttendance.RowUpdated, AddressOf FeeChargeAttendanceRowUpdated

Private Sub FeeChargeRowUpdated(ByVal sender As Object, ByVal e As SqlRowUpdatedEventArgs)
     Dim oCmd As SqlCommand = New SqlCommand("SELECT @@IDENTITY", e.Command.Connection)
     e.Row("ID") = oCmd.ExecuteScalar()
     e.Row.AcceptChanges()
End Sub

http://codeproject.com/cs/database/relationaladonet.asp</FONT>

Chris Pietschmann
Chris Pietschmann
Microsoft MVP | App Innovation Leader | Azure, AI & DevOps Architect | HashiCorp Ambassador | Author
I'm a Practice Leader, App Innovation specialist, solution architect, developer, SRE, trainer, and author with 25+ years of experience helping enterprises turn AI, app modernization, cloud architecture, and DevOps into real business outcomes.