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

itsallinthemind

Honorable
Oct 5, 2013
9
0
10,510
0
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
0
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;-)
 
Thread starter Similar threads Forum Replies Date
A Apps General Discussion 1
J Apps General Discussion 4
M Apps General Discussion 2
J Apps General Discussion 2
D Apps General Discussion 3
L Apps General Discussion 1
tarmiricmi Apps General Discussion 5
S Apps General Discussion 1
N Apps General Discussion 1
giantbucket Apps General Discussion 4
Archgaull Apps General Discussion 1
J Apps General Discussion 2
T Apps General Discussion 1
S Apps General Discussion 4
Z Apps General Discussion 7
T Apps General Discussion 1
B Apps General Discussion 15
J Apps General Discussion 11
N Apps General Discussion 4
Q Apps General Discussion 2

ASK THE COMMUNITY

TRENDING THREADS