Dim reader As SqlClient.SqlDataReader
Dim recordData As String = ""
Dim recordCount As Integer = 0
Dim i As Integer = 0
sqlConnection1.Open()
reader = sqlDataAdapter1.SelectCommand.ExecuteReader()
While reader.Read()
For i = 0 To reader.FieldCount - 1
recordData &= reader(i).ToString()
recordData &= "-"
Next
recordData &= ControlChars.CrLf
recordCount += 1
End While
sqlConnection1.Close()
MessageBox.Show("Records processed: " & recordCount)
MessageBox.Show("Data:" & ControlChars.CrLf & recordData)
This code example is also available as an IntelliSense code snippet. In the code snippet picker, it is located in Data - Designer features and ADO.NET. For more information, see How to: Insert Snippets Into Your Code (Visual Basic).