You can iterate through the DataColumns of a DataTable or you can use the
GetName method of the DataReader. See the code below.
--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada
Dim cn As New SqlConnection("Server=(local);Database=pubs;Integr ated
Security=SSPI;")
Dim da As New SqlDataAdapter("SELECT * FROM Authors", cn)
Dim dt As New DataTable
da.Fill(dt)
For Each dc As DataColumn In dt.Columns
ListBox1.Items.Add(dc.ColumnName)
Next
Dim dr As SqlDataReader
Dim i As Integer
cn.Open()
dr = da.SelectCommand.ExecuteReader(CommandBehavior.Clo seConnection)
For i = 0 To dr.FieldCount - 1
ListBox2.Items.Add(dr.GetName(i))
Next
dr.Close()
"Fred Nelson" <fr**@smartybird.com> wrote in message
news:u1**************@TK2MSFTNGP09.phx.gbl...
I have an app I'm working on where I would like to be able to access the
field names that are returned by a stored procedure. My stored
procedure will return about 140 fields
(select * from casemast where id=inid)
lots of data in a medical records system - I'm hoping I don't need to
create a class + parameters + etc.
I know that the field names can be displayed in a DataGrid - I don't
know how to get them otherwise - I'll use any data structure that will
let me get the names!
(I've seen lots of examples of how to read them from a datareader after
you define the fields yourself.)
Is there a data structre that supports this?
Thanks very much,
Fred