Get Column Names!

  • Thread starter Thread starter Arpan
  • Start date Start date
A

Arpan

Assume that a table in Access has the following 5 columns: PID, PName,
PDescription, PPrice & PDiscount. Now how do I get all the column names
in Access i.e. the query should retrieve the names of the
above-mentioned 5 columns (only the names, not the records)? In SQL
Server, the following query retrieves all the column names exisitng in
a database table:

----------------------------------------
SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE
TABLE_NAME='tblSheet' ORDER BY ORDINAL_POSITION
----------------------------------------

but using the above query to retrieve all the column names exisitng in
an Access table through an ASP application throws the following error:

Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Could not find file
'C:\WINNT\system32\INFORMATION_SCHEMA.mdb'.

So how does one get ONLY the COLUMN NAMES of a table in Access?

Thanks,

Arpan
 
The starting point is that you don't do it using SQL.
If you just want to populate a combobox or listbox with these field names,
you can set its RowSourceType to Field List and its RowSource to the name of
your table.
Otherwise, you'll need to use DAO or ADOX.

HTH
 
Back
Top