how to get column names in a table

G

Guest

Hi,

Does anyone know how to get the list of the column names in a given Access table using SQL? Would it be something like "Select column_name From table_name"?

Thanks for your help in advance!
 
T

Tom Ellison

Dear Jerry:

You can code to get the list of column names:

Dim rst As Recordset, i As Integer

Set rst = CurrentDb.OpenRecordset("YourTableName")
For i = 0 To rst.Fields.Count - 1
Debug.Print rst.Fields(0).Name
Next i

Replace YourTableName with the actual name of the table.

Tom Ellison
Microsoft Access MVP
Ellison Enterprises - Your One Stop IT Experts
 
G

Guest

Thanks but my project is done in C# and ADO.Net, and I am
still not sure how to accomplish that :-(

Jerry
-----Original Message-----
Dear Jerry:

You can code to get the list of column names:

Dim rst As Recordset, i As Integer

Set rst = CurrentDb.OpenRecordset("YourTableName")
For i = 0 To rst.Fields.Count - 1
Debug.Print rst.Fields(0).Name
Next i

Replace YourTableName with the actual name of the table.

Tom Ellison
Microsoft Access MVP
Ellison Enterprises - Your One Stop IT Experts
names in a given Access table using SQL? Would it be
something like "Select column_name From table_name"?
 
T

Tom Ellison

Dear anonymous:

Perhaps you would receive more relevant responses by posting to a
newsgroup that deals with the tools you are using. I'm hoping there
is a C# or ADO.Net equivalent to recordsets that would give you a
similar capacity. In fact, you might look for similar methods and
objects in the Help you have for your tools.

Tom Ellison
Microsoft Access MVP
Ellison Enterprises - Your One Stop IT Experts
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top