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 :-)
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 :-)
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
Try
countNames = BindingSource1.Count
last = countNames - 1
For i = 0 To countNames - 1
If i >= last Then
MsgBox("Last Name Entry: " & BindingSource1.Current("ChildName"))
Else
MsgBox(BindingSource1.Current("ChildName"))
BindingSource1.MoveNext()
End If
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try
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
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.