Home All Groups Group Topic Archive Search About

Fields in Access database returned in alphabetical order

Author
11 Mar 2006 5:54 PM
Julian
I'm using the following VB.Net code to retreive the field names of a table
in an Access db:

Dim NewField As ADOX.Column
Dim tblField As ADOX.Column

For Each tblField In adocat.Tables("tblData").Columns


The fields are returned in alphabetical order! I want to have the fields
returned in the order they were created. Can this be done?

-Julian

Author
11 Mar 2006 6:50 PM
Armin Zingler
Show quote Hide quote
"Julian" <ad***@jdmils.com> schrieb
> I'm using the following VB.Net code to retreive the field names of a
> table in an Access db:
>
> Dim NewField As ADOX.Column
> Dim tblField As ADOX.Column
>
> For Each tblField In adocat.Tables("tblData").Columns
>
>
> The fields are returned in alphabetical order! I want to have the
> fields returned in the order they were created. Can this be done?
>
> -Julian



It is not available in ADOX. Use DAO for native Jet support. See the
Ordinalposition property of the Field object. The DAO docu also says that
two fields can have the same ordinal position. More information:
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/office97/html/output/F1/D2/S5A2D1.asp


Armin
Author
12 Mar 2006 3:33 AM
Julian
How do you use DAO in VB.Net?

--
Show quoteHide quote
|
+-- Julian
|


"Armin Zingler" <az.nospam@freenet.de> wrote in message
news:e7k1tzTRGHA.2300@TK2MSFTNGP11.phx.gbl...
> "Julian" <ad***@jdmils.com> schrieb
>> I'm using the following VB.Net code to retreive the field names of a
>> table in an Access db:
>>
>> Dim NewField As ADOX.Column
>> Dim tblField As ADOX.Column
>>
>> For Each tblField In adocat.Tables("tblData").Columns
>>
>>
>> The fields are returned in alphabetical order! I want to have the
>> fields returned in the order they were created. Can this be done?
>>
>> -Julian
>
>
>
> It is not available in ADOX. Use DAO for native Jet support. See the
> Ordinalposition property of the Field object. The DAO docu also says that
> two fields can have the same ordinal position. More information:
> http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/office97/html/output/F1/D2/S5A2D1.asp
>
>
> Armin
Author
12 Mar 2006 12:31 PM
Armin Zingler
"Julian" <ad***@jdmils.com> schrieb
> How do you use DAO in VB.Net?


Set a reference to "Microsoft Data Access Objects". But you should probably
better have a look at Chris' answer.

See also: System.Data.OleDb.OleDbConnection.GetOleDbSchemaTable

and

http://msdn.microsoft.com/library/en-us/oledb/htm/oledbcolumns_rowset.asp
Column "ORDINAL_POSITION"

http://msdn.microsoft.com/library/en-us/oledb/htm/oledbprovjet_overview.asp
especially
http://msdn.microsoft.com/library/en-us/oledb/htm/oledbprovjet_supported_schema_rowsets.asp





Armin
Author
12 Mar 2006 5:27 AM
Chris
Armin Zingler wrote:
Show quoteHide quote
> "Julian" <ad***@jdmils.com> schrieb
>
>> I'm using the following VB.Net code to retreive the field names of a
>> table in an Access db:
>>
>> Dim NewField As ADOX.Column
>> Dim tblField As ADOX.Column
>>
>> For Each tblField In adocat.Tables("tblData").Columns
>>
>>
>> The fields are returned in alphabetical order! I want to have the
>> fields returned in the order they were created. Can this be done?
>>
>> -Julian
>
>
>
>
> It is not available in ADOX. Use DAO for native Jet support. See the
> Ordinalposition property of the Field object. The DAO docu also says
> that two fields can have the same ordinal position. More information:
> http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/office97/html/output/F1/D2/S5A2D1.asp
>
>
>
> Armin

You can get it in ADO which is the .net way of doing things.  There is a
function on the connection or command object called gettableschema that
will get you the info you want.

Chris
Author
12 Mar 2006 12:18 PM
Armin Zingler
Show quote Hide quote
"Chris" <no@spam.com> schrieb
> > It is not available in ADOX. Use DAO for native Jet support. See
> > the Ordinalposition property of the Field object. The DAO docu
> > also says that two fields can have the same ordinal position. More
> > information:
> > http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/office97/html/output/F1/D2/S5A2D1.asp
> >
> >
> >
> > Armin
>
> You can get it in ADO which is the .net way of doing things.  There
> is a function on the connection or command object called
> gettableschema that will get you the info you want.


I thought ADOX is even closer to DAO than ADO.Net. Therefore I did
not even think of doing it in ADO.Net. But your probably right.


Armin