Groups | Blog | Home
all groups > inetserver asp db > june 2004 >

inetserver asp db : ASP/Access 2002: how do I get column names from table (in order) using OLE DB?



Scotter
6/29/2004 3:50:16 AM
When I use ADOX to get columns(fields) of a table, they are *auto-sorted
alphabetically by name*.
I need to get the list of field names as they appear when I open the MDB
file and view details of the table, *not* sorted by field name
alphabetically.
I tried using open schema with following code causing this error msg: "Item
cannot be found in the collection corresponding to the requested name or
ordinal"
Set rsSchema = conn.OpenSchema(4, Array(Empty, Empty, "config"))
rsSchema.Sort = "ORDINAL_POSITION"
Thanks!
--
Scotter

lukezhan NO[at]SPAM online.microsoft.com
6/29/2004 8:36:46 AM
Hi Scotter,

Have you set the cursor's location to client side? I have tested following
code and it seems to work:

Dim rsSchema
Dim cnn

Set cnn = CreateObject("ADODB.connection")

cnn.CursorLocation = 3
cnn.Provider = "Microsoft.Jet.OLEDB.4.0;"
cnn.Open "Data Source=C:\db1.mdb;"

Set rsSchema = cnn.OpenSchema(4, Array(Empty, Empty, "table1"))
rsSchema.Sort = "ORDINAL_POSITION"


Luke
Aaron [SQL Server MVP]
6/29/2004 9:37:47 AM
Why do you keep posting the same message multiple times? Hitting send once
is usually sufficient.

http://www.aspfaq.com/search.asp?q=schema

--
http://www.aspfaq.com/
(Reverse address to reply.)




[quoted text, click to view]

Scotter
6/30/2004 5:09:38 AM
Thanks! Yeah problem was I left out the cursorlocation=3

[quoted text, click to view]

AddThis Social Bookmark Button