Return to Snippet

Revision: 49676
at July 28, 2011 03:17 by indra


Updated Code
Me.DialogResult = Windows.Forms.DialogResult.None

'sample usage

Try
    mybindingsource.EndEdit()
    en.SaveChanges()
    MessageBox.Show("Data successfully saved", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch ex As Exception
    If ex.InnerException.ToString.Contains("PRIMARY KEY") Then
        MessageBox.Show("Duplicate record", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Me.DialogResult = Windows.Forms.DialogResult.None
    End If
End Try

Revision: 49675
at July 28, 2011 03:03 by indra


Initial Code
Me.DialogResult = Windows.Forms.DialogResult.None

'sample usage

Try
            mybindingsource.EndEdit()
            en.SaveChanges()
            MessageBox.Show("Data successfully saved", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Catch ex As Exception
            If ex.InnerException.ToString.Contains("PRIMARY KEY") Then
                MessageBox.Show("Duplicate record", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Me.DialogResult = Windows.Forms.DialogResult.None
            End If
        End Try

Initial URL

                                

Initial Description

                                

Initial Title
Cancel dialog result from closing form

Initial Tags
validation

Initial Language
VB.NET