Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Creating MDB in VB.Net

0 views
Skip to first unread message

Stas Tristan

unread,
Jul 31, 2002, 8:47:21 AM7/31/02
to
Hello, Experts!
How from Vb.Net create the MDB-database, then table and then fields and
indexes of different types.
MS Access is not installed (only MSDAC 2.7)

How can I do this task:
a) via code
b) via designer mode (if this possible)

Thanx!


Paul Clement

unread,
Jul 31, 2002, 3:34:32 PM7/31/02
to
On Wed, 31 Jul 2002 16:47:21 +0400, "Stas Tristan" <s_tr...@ua.fm> wrote:

¤ Hello, Experts!

You can add the ADOX to your VB.NET project to do this:

Private Sub CreateAccess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles CreateAccess.Click

Dim tbl As New ADOX.Table()
Dim col As New ADOX.Column()
Dim cat As New ADOX.Catalog()

'Engine Type=4 is Access 97 and a value of 5 is Access 2000
cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=d:\My Documents\db10.mdb;" & _
"Jet OLEDB:Engine Type=4;")

tbl.Name = "NewTable"
col.Name = "DateField"
col.Type = ADOX.DataTypeEnum.adDate
tbl.Columns.Append(col)
col = New ADOX.Column()
col.Name = "Address2"
col.Type = ADOX.DataTypeEnum.adVarWChar
col.DefinedSize = 20
col.Attributes = ADOX.ColumnAttributesEnum.adColNullable
tbl.Columns.Append(col)
col = New ADOX.Column()
col.Name = "Age"
col.Type = ADOX.DataTypeEnum.adInteger
col.Attributes = ADOX.ColumnAttributesEnum.adColNullable
tbl.Columns.Append(col)
cat.Tables.Append(tbl)

cat.Tables("NewTable").Columns("Address2").Properties("Jet OLEDB:Allow Zero Length").Value =
True

End Sub


Paul ~~~ pcle...@ameritech.net
Microsoft MVP (Visual Basic)

0 new messages