Nick Mackenzie
Nick Mackenzie

Reputation: 59

Display Array in message box vb.net

The code below checks for unapproved pledges in a table and notifies the user if there are unapproved pledges.However,i would like to display all the unapproved PledgeIDs to the user through a message box. Kindly assist

sql = "SELECT PledgeID FROM tblpledges WHERE Status=@status"
        command = New OleDbCommand(sql, connection)
        command.Parameters.Add(New OleDbParameter("@status", OleDbType.VarChar)).Value = "Unapproved"
        reader = command.ExecuteReader
        If reader.HasRows Then
            errmsg = "You Have Some Unapproved Pledges"
        End If

        If errmsg <> "" Then
            MessageBox.Show(errmsg)
            Return False
        Else
            Return True
        End If

Upvotes: 0

Views: 3619

Answers (1)

boop_the_snoot
boop_the_snoot

Reputation: 3247

Modify your code to :

Dim pledgeIDs As New List(Of String) 'Add this
If reader.HasRows Then
    Do While reader.Read()
       pledgeIDs.Add(reader.GetString(0))          
    Loop
    MessageBox.Show("You Have Some Unapproved Pledges : " & String.Join(",", pledgeIDs))
End If

Upvotes: 3

Related Questions