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,745 of 10,840   
   Raoul Watson to Jason Keats   
   Re: detecting unique primarykey in ADODC   
   28 Apr 09 01:32:57   
   
   From: WatsonR@IntelligenCIA.com   
      
   Jason Keats wrote:   
   >>   
    >>    
   >   
   > 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?   
      
   Over 10 years ago, I have an app, which database was created in the jet   
   space like so:   
      
   Set MyWs = DBEngine.Workspaces(0)   
   Set MyDb = MyWs.CreateDatabase(dbFileName, dbLangGeneral)   
   ' Create new TableDef for extension table.   
   Set mytd = MyDb.CreateTableDef(gTable)   
   ' Add fields to MyTableDef.   
   For x = 1 To maxfield   
          Set AuFlds(x) = mytd.CreateField(fieldname(x)),fieldtype   
        ' don't allow null   
          AuFlds(x).AllowZeroLength = false   
   Next   
      
   For x = 0 To maxfield - 1   
        mytd.Fields.Append AuFlds(x)   
   Next x   
      
   ' Now add an Index.   
   Set AuIdx = mytd.CreateIndex(gKey)   
        AuIdx.Primary = True  '***PRIMARYKEY   
        AuIdx.Unique = False  '***NOT unique allowed   
      
   Set IxFlds(0) = AuIdx.CreateField(gKey)   
   ' Append Field to Fields collection of Index object.   
   AuIdx.Fields.Append IxFlds(0)   
   ' Append Index to Indexes collection.   
   mytd.Indexes.Append AuIdx   
   ' Append TableDef to TableDefs collection.   
   MyDb.TableDefs.Append mytd   
   MyDb.Close   
   '======================================================   
      
   Years later, I converted the user database to require a unique key.   
      
   So now basically, I have two customer bases, those with the older   
   database and those with the newer (they are all over ten years old).   
      
   I am about to revamp my app but unfortunately, using my ADODC control, I   
   just don't know how to test the index field to find out whether it is   
   the oldest database or a newer one.   
      
   I have a way around it by doing things unsupported in the older database   
   and catch the errors, but I figured there has to be an easier way to   
   test the index keyfield.   
      
   Like I said, if I use Jet for the data control, I can test it by using:   
   If DBControl.Database.TableDefs("tblname").Indexes("fieldname").Unique   
   Then 'it is a real old DB   
      
   Hope that explains it.   
      
   --- 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