This project is read-only.

Duplicate audit records?

Nov 23, 2010 at 8:57 PM

I've got a form that (in the codebehind) adds a customer, gets its ID, and uses that to create an associated service location record.

Both records get inserted ok into the primary tables, but both also are shown as inserts to the database twice in the audit tables!


                Dim db As New MyDataContext

                Dim customer As New Customer

                With customer
                    .Customer = txtCustomer.Text

                    If Not String.IsNullOrEmpty(txtNickname.Text) Then
                        .Nickname = txtNickname.Text
                    End If

                    If ddlAffiliateOf.SelectedIndex > -1 Then
                        .AffiliateOf = ddlAffiliateOf.SelectedItem.Value
                    End If

                    If Not String.IsNullOrEmpty(txtNickname.Text) Then
                        .Nickname = txtNickname.Text
                    End If

                    If Not String.IsNullOrEmpty(txtPhone.Text) Then
                        .Phone = txtPhone.Text
                    End If

                    If Not String.IsNullOrEmpty(txtFax.Text) Then
                        .Fax = txtFax.Text
                    End If

                    If Not String.IsNullOrEmpty(txtUrl.Text) Then
                        .Url = txtUrl.Text
                    End If

                    If Not String.IsNullOrEmpty(txtBroadsoftGroupName.Text) Then
                        .BroadsoftGroupName = txtBroadsoftGroupName.Text
                    End If

                    .IsWholesaler = chkIsWholesaler.Checked
                End With



                Dim customerId As Integer = customer.CustomerId

                Dim serviceLocation As New ServiceLocation

                With serviceLocation
                    .CustomerId = customerId

                    .Street = txtStreet.Text

                    If Not String.IsNullOrEmpty(txtAddlStreet.Text) Then
                        .AddlStreet = txtAddlStreet.Text
                    End If

                    .City = txtCity.Text
                    .StateProvince = ddlStateProvince.SelectedItem.Value
                    .PostalCode = txtPostalCode.Text
                End With



            Catch ex As Exception
                lblError.Text = ex.Message.ToString
            End Try
Changes are submitted twice to the data context ... is that what is causing the double recording as inserts?

Nov 23, 2010 at 9:17 PM

Fixed with

I thought I had searched thoroughly before posting my question - apologies for the bandwidth.