|
-
Oct 4th, 2000, 06:18 AM
#1
Thread Starter
New Member
I have an Access 97 database, and I need to get the column names from a specific table and use these as headings in a listview control. Can this be done through the data control in VB or do I need to use some kind of SQL statement?
Even just an example on how to get metadata from an access database would be great.
Thanks
-
Oct 5th, 2000, 02:05 PM
#2
New Member
I think this would work:
Dim db as Database
Dim tDef as TableDef
dim i as Integer
dim arrColumnNames() as String
Set db = OpenDatabase("c:\databases\somedatabase.mdb")
Set tDef = db.Tabledefs("NameOfYourTable")
Redim arrColumnNames(0 to tdef.fields.count)
For i = 0 to tdef.fields.count
arrColumnNames(i)=tDef.Fields(i).Name
Next i
Set tdef = Nothing
Set db = Nothing
That's the DAO way to do it. You could also do it using
ADO(X), but I still find DAO easier to work with for
Access databases. Just old-fashioned I guess. Hope this
helps.
G.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|