Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting all the fields from a table in a SQL Server?

Status
Not open for further replies.

99mel

Programmer
Oct 18, 1999
379
GB
Hi all,

Does anybody know how I can simply get all the field names from a database table in SQL Server? without using a stored procedure?

thanks in advance

Mel


 
Hi

Try this:

Code:
Dim oConn as ADODB.Connection
Dim oRS as ADODB.RecordSet
Dim i as Long

Set oConn = new Connection
' Open your connection

Set oRS = new RecordSet
oRS.Open tablename, oConn, , , adCmdTable

For i = 0 To oRS.Fields.Count - 1
  Debug.Print oRS.Fields(i).Name
Next

Chaz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top