mister.magoo (4/8/2013)
Lowell (4/8/2013)
I've done this a few times;here's a link to a slightly modified version of Microsofts Microsoft.ApplicationBlocks.Data SQLHelper.cs class, which i ran thru a converter, and then enhanced.
Lowell, that code references a "frmErrors" object, which might be a bit of a hiccup for people - do you have a version without it?
ahh darn i forgot about that; thank you for finding that, MM!
the code as posted would be handy for me, not so handy for folks without my whole source code.
I've modified the code i posted to just throw up a messagebox instead.
the code snippet was changed to this instead:
Public Shared Function ShowErrors()
If SqlHelper.ErrorMessages.Count > 0 Then
'This example below passed both error collectiosn to a form i had made; code below modified to simply throw up a MessageBox:
'frmErrors.ShowMe(Nothing, SqlHelper.ErrorMessages, SqlHelper.InfoMessages)
Dim results As String = "ErrorMessages: " & vbCrLf
For x As Integer = 0 To SqlHelper.ErrorMessages.Count - 1
results = results & SqlHelper.ErrorMessages(x) & vbCrLf
Next
results = results & "InfoMessages: " & vbCrLf
For x As Integer = 0 To SqlHelper.InfoMessages.Count - 1
results = results & SqlHelper.InfoMessages(x) & vbCrLf
Next
MsgBox(results)
SqlHelper.ErrorMessages.Clear()
SqlHelper.InfoMessages.Clear()
End If
End Function
Public Shared Function ShowErrors(ByVal KeepMessages As Boolean)
If SqlHelper.ErrorMessages.Count > 0 Then
'This example below passed both error collectiosn to a form i had made; code below modified to simply throw up a MessageBox:
'frmErrors.ShowMe(Nothing, SqlHelper.ErrorMessages, SqlHelper.InfoMessages)
Dim results As String = "ErrorMessages: " & vbCrLf
For x As Integer = 0 To SqlHelper.ErrorMessages.Count - 1
results = results & SqlHelper.ErrorMessages(x) & vbCrLf
Next
results = results & "InfoMessages: " & vbCrLf
For x As Integer = 0 To SqlHelper.InfoMessages.Count - 1
results = results & SqlHelper.InfoMessages(x) & vbCrLf
Next
MsgBox(results)
If Not KeepMessages Then
SqlHelper.ErrorMessages.Clear()
SqlHelper.InfoMessages.Clear()
End If
End If
End Function
Lowell