home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.visual.basic      MS Visual Basic discussions, NOT dot-net      10,840 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 10,744 of 10,840   
   Jason Keats to Raoul Watson   
   Re: detecting unique primarykey in ADODC   
   27 Apr 09 13:17:07   
   
   From: jkeats@melbpcDeleteThis.org.au   
      
   Raoul Watson wrote:   
   > Jason Keats wrote:   
   >> Raoul Watson wrote:   
   >>> Using the old MSJet engine,   
   >>> I can detect a unique key by checking:   
   >>>   
   >>> If   
   >>> DBControl.Database.TableDefs("tblname").Indexes("fieldname").Unique Then   
   >>>   
   >>> Can someone help me on a way   
   >>> how can this be done on an ADODC ?   
   >>>   
   >>> I need to determine if the primarykey field in   
   >>> the DB requires a unique key..   
   >>> (I know the DB and field name)   
   >>>   
   >>> Any help is greatly appreciated. Thanks!!   
   >>   
   >>   
   >> What I think you should be investigating is:   
   >>   
   >> rst.Fields("fieldname").Properties.Item("KEYCOLUMN").Value   
   >>   
   >> If False, then it's not a primary key.   
   >>   
   >>   
   > Thanks Jason.. unfortunately I am looking to find out if the primarykey   
   > field requires a unique value..   
      
   I don't know what type of database (Jet/SQL Server/etc) you're using,   
   but in my experience primary keys are always: unique, indexed and   
   mandatory (not null).   
      
   They are also either created by the database (ie, identity/autonumber   
   fields), or inserted with the rest of the data (eg, GUIDs).   
      
   How can you go wrong? You can't, unless you've stuffed up the creation   
   of the table.   
      
   That's why I thought you wanted to know whether or not you'd remembered   
   to create a primary key field for your table. The information I supplied   
   works if you're using SQL Server with an Identity PK. I have not tested   
   it with other databases.   
      
   I guess I still don't understand your question. What do you mean by "I   
   am looking to find out if the primary key field requires a unique value."?   
      
   How can it not?   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca