All,
Does anyone know how to add a primary key to a table using SQLDMO? When I try it with the code below the oTable.primarykey object = nothing. Any ideas would be great.
Here's the code,
Dim oKey As New SQLDMO.Key()
....
oKey.KeyColumns.Add(listFields.Items(I).Text)
oTable.PrimaryKey.Type = SQLDMO.SQLDMO_KEY_TYPE.SQLDMOKey_Primary
oTable.PrimaryKey.Clustered = False
oTable.PrimaryKey.KeyColumns.Add(oKey.KeyColumns.Item(0))
Thanks
Jim