I have written a program which uses a SQL exception class and then use it show custom messages for the primary key violation. Also i want the primary key value that caused the violation. How can i get all the primary keys which generated the exception from the sqlexception object.
Catch se As SqlException
For i As Integer = 0 To se.Errors.Count - 1
Select Case se.Errors(i).Number.ToString
Case "2627" ''Primary Key Violation
Dim drH As DataRow = _ErrorDataSet.NewRow
drH.Item("Module") = _mod
drH.Item("Code") = ""
drH.Item("Description") = ""
drH.Item("Error") = "Document Number Already Exists"
_ErrorDataSet.Rows.Add(drH)
Next
End Try