Results 1 to 3 of 3

Thread: Creating a primary key

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    455

    Post

    Hello dear VB users,

    Can somebody tell me how set to the field "NewField" to a primairy key:


    Set Ws = DBEngine.Workspaces(0)
    Set Db = Ws.CreateDatabase(DbSettings, dbLangGeneral)
    Dim tdfNew As TableDef

    Set tdfNew = Db.CreateTableDef("newTable")
    tdfNew.Fields.Append tdfNew.CreateField("NewField", dbText)

    tdfNew.Fields("newfield").DefaultValue = "new"

    Db.TableDefs.Append tdfNew
    Db.Close

    Nice greetings,

    Michelle.

  2. #2
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    try something like:

    Field.Attributes(dbAutoIncrField) = TRUE/1/YES (one of those)

    Check out the FieldAttributeEnum enumeration in the object browser for other values you can use

  3. #3
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105

    Post

    Following SQL should work in SQL Server:

    Alter table newtable add constraint pk_Newfield PRIMARY KEY newfield

    [This message has been edited by JHausmann (edited 02-07-2000).]

Posting Permissions

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



Click Here to Expand Forum to Full Width