BindingSource AddNew Failed

stevecking

Active member
Joined
Dec 27, 2006
Messages
32
Programming Experience
5-10
I've a form that contains a master BindingSource with related binding sources which are releated by the foreign key. My difficulty is that the users within the Intranet have both successes and failures using the sub BindingSources to add new records. The Server containing the database is local and I, as developer, have no problems adding the the binding sources, but users who are not local are having consistent failures. The ID field is an Identity(1,1) integer field so I check for a value <> 0 when creating the new record in the dataset. The user is able to fill in the fields normally but after closing the form and reopening it was obviously now saved. This has been verified with query analyzer. The application design does not save the data until the form is closed so I don't feel good about it being a network issue. Any help would be appreciated.

Dim bs As New BindingSource
Dim view As New Data.DataView
Dim drv As Data.DataRowView = Nothing

Try
If Me.cboPnSru.Enabled = False Then
EnableSruControls(True)
End If

bs = CType(sender, BindingSource)
view = CType(bs.List, Data.DataView)

If (Not view Is Nothing) Then
drv = CType(view.AddNew, Data.DataRowView)
End If

If (Not drv Is Nothing) Then
drv.Item("PN") = ""
drv.Item("Cage") = ""
drv.Item("Name") = ""
drv.Item("NSN") = ""
drv.Item("SOS") = ""
drv.Item("QPA") = 0
drv.Item("FailRate") = 0D
drv.Item("ChgDate") = Now

'Tell it that this is the new row.
e.NewObject = drv

' Save the new ID from the record
_SruID = drv.Item("ID")

If _SruID = 0 Then
' This row is not created properly
MsgBox("The SRU record was not created")
Exit Sub
End If


' Now move to the new record
bs.MoveLast()

bsPprSruLinks.AddNew()


End If
 
Back
Top