I just have a table named RCS_2002.
A field named Z
I need to set via adox idx unique=false (duplicati ammessi)
how to with ADOX?
set idx unique=false
-
- PlatinumLounger
- Posts: 4357
- Joined: 26 Apr 2010, 17:36
set idx unique=false
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78507
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: set idx unique=false
Try this as starting point:
Code: Select all
Sub Test()
Dim cat As ADOX.Catalog
Dim tbl As ADOX.Table
Dim idx As ADOX.Index
On Error GoTo ErrHandler
'Open the catalog.
Set cat = New ADOX.Catalog
cat.ActiveConnection = ...
'Refer to the table
Set tbl = cat.Tables("RCS_2002")
' Define index.
Set idx = New ADOX.Index
idx.Name = "MyIndex"
'Add column "Z"
idx.Columns.Append "Z"
'Not unique
idx.Unique = False
'Append the index to the table.
tbl.Indexes.Append idx
ExitHandler:
'Clean up.
On Error Resume Next
Set cat.ActiveConnection = Nothing
Set cat = Nothing
Set tbl = Nothing
Set idx = Nothing
Exit Sub
ErrHandler:
MsgBox Err.Description, vbExclamation
Resume ExitHandler
End Sub
Best wishes,
Hans
Hans