 |
| View previous topic :: View next topic |
| Author |
Message |
Avis Junior Poster

Joined: 07 Oct 2003 Posts: 510 Location: India
|
Posted: Oct 24th, 2003 04:41 AM Post subject: How to make an Indexed Field ? |
|
|
Hello!
I am using the following code to create database at runtime.
| Code: | Dim strConnection As String
Dim objCat As ADOX.Catalog
Dim objTable As New ADOX.Table
Dim objCol As New ADOX.Column
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
App.Path & "\Excise.mdb"
Set objCat = New ADOX.Catalog
'objCat.Create strConnection
objCat.ActiveConnection = strConnection
With objCol
.Name = "ID"
.Type = adInteger
Set .ParentCatalog = objCat
.Properties("AutoIncrement") = True
End With
With objTable
.Name = "Item"
.Columns.Append objCol
.Columns.Append "Code", adVarWChar, 6
.Columns.Append "Description", adVarWChar, 50
.Columns.Append "Identity", adVarWChar, 10
.Columns.Append "Tariff", adVarWChar, 10
.Columns.Append "Packing", adVarWChar, 10
.Columns.Append "UOM", adVarWChar, 5
.Columns.Append "Retail", adVarWChar, 10
End With
objCat.Tables.Append objTable
Set objTable = Nothing
Set objCat = Nothing |
Now as you can see there's a field named Code. What i really want to do is that i want the Indexed property of that field to be set as "Indexed - yes no duplicates". The database is MS Access.
I hope you get what i am trying to do.
Thanks! _________________ Code Snippets, Tutorials, Utilities, Controls
Low cost Web Hosting
Hosting starts at as low as $4 per year!
Always follow posting guidelines
Put your VB code in [vb ] your code [ /vb] tags! |
|
| Back to top |
|
ritchieroo Newbie
Joined: 27 Oct 2003 Posts: 8
|
Posted: Oct 27th, 2003 07:30 AM Post subject: |
|
|
| Code: |
Set objIndex = New ADOX.Index
With objIndex
.Name = "IX_Item_1"
.Unique = True
.Columns.Append "Code", adVarWChar, 6
End With
objTable.Indexes.Append objIndex
|
|
|
| Back to top |
|
Avis Junior Poster

Joined: 07 Oct 2003 Posts: 510 Location: India
|
|
| Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|