If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > ADOX Columns and Keys

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-15-04, 09:29
seems1 seems1 is offline
Registered User
 
Join Date: Jul 2004
Location: UK
Posts: 2
Question ADOX Columns and Keys

Hi,

I am having some difficulty using ADOX to retreive information ABOUT a database. (Not FROM it).

I want to know how (or if) it is possible to determine whether a Column in the Columns collection of an ADOX Table object is a Key column.

I am running the following code:

Code:
for each column in tableObj.Columns
   if(column.RelatedColumn = "") then
      response.write(column.name & "<br/>")
   end if
next
The problem is that I get an error because I am trying to access the RelatedColumn property of non-Key columns.

The online MSDN documentation is very unclear on this issue, RelatedColumn IS listed as a property of Column, but with the proviso that is only "for key columns". However the rest of the documentation indicates that Keys and Columns are entirely seperate objects with their own collections inside Table objects.

What i am trying to do is populate a drop down list with the names of all Columns that are NOT keys, but how can I determine which ones these are?

All help greatly appreciated!
Reply With Quote
  #2 (permalink)  
Old 07-15-04, 19:12
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
I've never tried to use this before but I just had a look through MSDN. What you are doing would appear to be fine but from what you are saying I can understand what is happening....

This isn't an elegant solution but it may help...

Code:
on error resume next
for each column in tableObj.Columns
   if(column.RelatedColumn = "") then
      if err.number = 0 then response.write(column.name & "<br/>")
   end if
   if err.number <> 0 then err.clear
next
on error goto 0
I wonder if there is a way to go through the properties collection of the column and determine if one of the properties is RelatedColumn and only if it is to grab it.... something like...

Code:
for each column in tableObj.Columns
   for each property in column.properties
      if property.name = "RelatedColumn" then
         if(column.RelatedColumn = "") then response.write(column.name & "<br/>")
      end if
   end if
next
HTH
Reply With Quote
  #3 (permalink)  
Old 07-16-04, 05:53
seems1 seems1 is offline
Registered User
 
Join Date: Jul 2004
Location: UK
Posts: 2
Arrow Thanks,

That seems a good idea, should have thought of it myself, thanks.

Regarding checking properties, apparently the contents of the properties collection depends on the Data Provider, and although this appears to be documented for ADO, I could find nothing for ADOX about this.

Thanks for your help!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On