Need help: Create Access Database programmatically using VB .NET

G

Guest

Hello, i am using ADOX + VB .NET to create a Access Database
programmatically. I plan to set some properties of the column such primary
key.
The code is as follows:

Dim cat As ADOX.Catalog
Dim tbl As ADOX.Table
Dim idx As ADOX.Index
Dim prp As ADOX.Property

Set cat = New ADOX.Catalog
cat.ActiveConnection = CurrentProject.Connection
Set tbl = New ADOX.Table

With tbl
..Name = "tblExperimental"
..ParentCatalog = cat
..Columns.Append "CustID", adInteger
..Columns("CustID").Properties("Autoincrement") = True
..Columns("CustID").Properties("Increment") = CLng(3)
..Columns("CustID").Properties("Seed") = CLng(2004000)
..Columns.Append "Name", adVarWChar, 5
..Columns("Name").Properties("Nullable") = True
..Columns.Append "Rating", adInteger
..Columns("Rating").Properties("Description") = "Customer Rating"
..Columns("Rating").Properties("Jet OLEDB:Column Validation Text") = "Must be
between 1 and 10"
..Columns("Rating").Properties("Jet OLEDB:Column Validation Rule") = ">0 and
<11"
..Columns("Rating").Properties("Default") = 5
End With

cat.Tables.Append tbl

Set idx = New ADOX.Index

With idx
..Name = "PrimaryKey"
..Columns.Append "CustID"
..PrimaryKey = True
..Unique = True
End With

tbl.Indexes.Append idx

Set idx = Nothing
Set cat = Nothing


when I run the program, it always issue some error: type is invalid.

Can anyone tell me how should I correct my code?
 
C

Cor Ligthert

Sunlight,

Because ADOX has in connection with VBNet a low use, there is probably a
better newsgroup for your question

microsoft.public.data.ado

It has a medium/low activity however I have seen that almost every question
get an answer.

There are people active in that newsgroup who know VBNET.

I hope this helps anyway

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top