Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » Database & Reporting

Post new topic   Reply to topic
How to make an Indexed Field ?
View previous topic :: View next topic  
Author Message
Avis
Junior Poster


Joined: 07 Oct 2003
Posts: 510
Location: India

PostPosted: Oct 24th, 2003 04:41 AM    Post subject: How to make an Indexed Field ? Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger ICQ Number
ritchieroo
Newbie


Joined: 27 Oct 2003
Posts: 8

PostPosted: Oct 27th, 2003 07:30 AM    Post subject: Reply with quote

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
View user's profile Send private message
Avis
Junior Poster


Joined: 07 Oct 2003
Posts: 510
Location: India

PostPosted: Oct 27th, 2003 07:59 AM    Post subject: Reply with quote

Thanks ritchieroo and welcome to the forum! ;-)
_________________
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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger ICQ Number
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » Database & Reporting All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic