How to loop inside a database and display its result in a msgbox??..

itsallinthemind

Honorable
Oct 5, 2013
9
0
10,510
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 :)
 

Ijack

Distinguished
The details depends upon what database you are using. But basically it is the same as any other programming loop.

1. Read the first record.
2. Extract name from record and display it in messagebox.
3. Was this the last record? If so goto 6
4. Read next record.
5. Goto 2.
6. End.

So, what exactly is your problem?
 

itsallinthemind

Honorable
Oct 5, 2013
9
0
10,510
Public Class frmTest
Private Sub DBLoadNames()
Dim i, countNames, last As Integer

countNames = BindingSource1.Count
last = countNames - 1

For i = 0 To countNames
If i = last Then
MsgBox("Last Name Entry: " & BindingSource1.Current("ChildName"))
Exit For
End If
MsgBox(BindingSource1.Current("ChildName"))
BindingSource1.MoveNext()
Next

End Sub
Private Sub frmTest_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ChildNameTableAdapter.Fill(TestDataSet.ChildName)
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

Thanks...I got it already...thanks my friend;-)
 

TRENDING THREADS