PDA

Click to See Complete Forum and Search --> : Creating a primary key


michelle
Feb 4th, 2000, 09:12 PM
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.

Clunietp
Feb 6th, 2000, 06:21 AM
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

JHausmann
Feb 6th, 2000, 11:20 AM
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).]