J
jaYPee
is there a way to know if the form is edited or not after calling
addnew? Me.BindingContext(DsStudentCourse1, "Students").AddNew()
because i got an error after closing the form. because in my form
closing event i have a code to call the EndCurrentEdit to determine if
the dataset has changes or not. here is my code in closing event
Private Sub Students_Closing(ByVal sender As Object, ByVal e
As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
Me.BindingContext(DsStudentCourse1,
"Students").EndCurrentEdit()
Try
If DsStudentCourse1.HasChanges Then
If MessageBox.Show("There are unsave changes in
the Form, Yes to Save, No to Discard and exit?", "Save changes",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes
Then
Save_Record()
Else
Me.BindingContext(DsStudentCourse1,
"Students").CancelCurrentEdit()
End If
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
the problem is in the Me.BindingContext(DsStudentCourse1,
"Students").EndCurrentEdit() line of code after calling addnew and
then closing the form without editing the form.
the error generated is "Column 'IDNo' does not allow nulls." because
IDNo is a primary key.
thanks in advance for any help.
addnew? Me.BindingContext(DsStudentCourse1, "Students").AddNew()
because i got an error after closing the form. because in my form
closing event i have a code to call the EndCurrentEdit to determine if
the dataset has changes or not. here is my code in closing event
Private Sub Students_Closing(ByVal sender As Object, ByVal e
As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
Me.BindingContext(DsStudentCourse1,
"Students").EndCurrentEdit()
Try
If DsStudentCourse1.HasChanges Then
If MessageBox.Show("There are unsave changes in
the Form, Yes to Save, No to Discard and exit?", "Save changes",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes
Then
Save_Record()
Else
Me.BindingContext(DsStudentCourse1,
"Students").CancelCurrentEdit()
End If
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
the problem is in the Me.BindingContext(DsStudentCourse1,
"Students").EndCurrentEdit() line of code after calling addnew and
then closing the form without editing the form.
the error generated is "Column 'IDNo' does not allow nulls." because
IDNo is a primary key.
thanks in advance for any help.