Primary keys...

Results 1 to 2 of 2

Thread: Primary keys...

  1. #1
    Join Date
    Dec 1969

    Default Primary keys...

    I need to write an sql statement to add an autonumber (primary key) to a field in an Access database, using UltraDev but can&#039t think what to do?! THe primary key field does not appear in the web page (which is a page specifically for inserting a record...any ideas?

  2. #2
    lagerBoy Guest

    Default RE: Primary keys...

    Here&#039s some sample code from an Access project, so it might need some alteration for the web....<BR><BR>Dim cat As ADOX.Catalog<BR>Dim tbl As ADOX.Table<BR>Dim idx As ADOX.Index<BR><BR>Set cat = New ADOX.Catalog<BR>cat.ActiveConnection = CurrentProject.Connection<BR><BR>&#039Create new Table<BR>Set tbl = New ADOX.Table<BR><BR>&#039Add field to Table<BR>With tbl<BR> .Name = "tblFoods"<BR> Set .ParentCatalog = cat<BR> .Columns.Append "FoodID", adInteger<BR> .Columns("FoodID").Properties("AutoIncrement") = True<BR>End With<BR><BR>cat.Tables.Append tbl<BR><BR>Set idx = New ADOX.Index<BR>idx.Name = "PrimaryKey"<BR>idx.Columns.Append "FoodID"<BR>idx.PrimaryKey = True<BR>idx.Unique = True<BR>tbl.Indexes.Append idx<BR><BR>Set idx = Nothing<BR>Set cat = Nothing<BR><BR>This example was taken from the book "Mastering Microsoft Access2000 Development" by Alison Balter.<BR><BR>You should also check out a really, really cool article:<BR><BR><BR>Cheers,<BR>lagerBoy<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts