• 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.

    SqlHelper.vb.txt

    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


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!