0

Hello,
I would like to get message, or true result when DataSet get new record (new row). But, I always get message as "no".

Button1 is add new record

Me.Table1BindingSource.AddNew()

Button2 is save a record

Me.Validate()
        Me.Table1BindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.TestDataSet)

Button3 should return "Yes" as new record has been added, but does not?!

If TestDataSet.HasChanges(DataRowState.Added) Then
            MsgBox("yes")
        Else
            MsgBox("no")
        End If

Thank you in advance for help.

2
Contributors
2
Replies
6
Views
5 Years
Discussion Span
Last Post by dejanc
0

Hi, try the code below, it worked for me,

'check if the datasets row state = added
if me.dataset.table.row(me.bindingsource.position).rowstate = datarowstate.added then

messagebox.show("yes")

else

messagebox.show("no")

endif
0

Thanks for reply.
I have found that order of executes was wrong. After EndEdit I got True values as "yes".

Me.Validate()        
Me.Table1BindingSource.EndEdit()   

If TestDataSet.HasChanges(DataRowState.Added) Then            
MsgBox("yes")        
Else           
MsgBox("no")        
End If 
     
Me.TableAdapterManager.UpdateAll(Me.TestDataSet
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.