| Platform: | Visual Basic |
| Task: | Get the column names from a DataReader object |
| Discussion: | Get the column names from a DataReader object |
| Example: | Private Sub GetDataReaderColumns()
Dim MySqlConnection As New SqlConnection("Data Source=" & SQLServer & ";Initial Catalog=" & DB & ";Trusted_Connection=True;")
MySqlConnection.Open()
Dim MySqlCommand As SqlCommand = New SqlCommand("SELECT CaribouID,FixDate,FixDateAST FROM CaribouLocations ORDER BY CaribouID", MySqlConnection)
Dim MyDataReader As SqlDataReader = MySqlCommand.ExecuteReader
For i As Integer = 0 To MyDataReader.FieldCount - 1
Me.EditorRichTextBox.AppendText(MyDataReader.GetName(i).ToString & vbNewLine)
Next
MySqlConnection.Close()
End Sub |