Hi EveryOne:-) I hope everyone is doing great...

I have a question..

I have a table in a database and it contains 20 names

How to loop in a database and display each name in a msgbox??

Thanks :-)

Recommended Answers

All 2 Replies

Show us what you have so far. We don't know what kind of database you are using or how you want to connect. Are you using ADO, OleDB, SqlClient?

Here is it Reverend Jim :-) actually i got it already...

Public Class From1
    Private Sub DBLoadNames()
        Dim i, countNames, last As Integer

            countNames = BindingSource1.Count
            last = countNames - 1

            For i = 0 To countNames - 1
                If i >= last Then
                    MsgBox("Last Name Entry: " & BindingSource1.Current("ChildName"))
                End If
        Catch ex As Exception
        End Try
    End Sub

    Private Sub frmTest_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    End Sub
    Private Sub DisplayButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DisplayButton.Click
        Call DBLoadNames()
    End Sub
    End Class
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.