Google Groepen ondersteunt geen nieuwe Usenet-berichten of -abonnementen meer. Historische content blijft zichtbaar.

Creating MDB in VB.Net

0 weergaven
Naar het eerste ongelezen bericht

Stas Tristan

ongelezen,
31 jul 2002, 08:47:2131-07-2002
aan
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

ongelezen,
31 jul 2002, 15:34:3231-07-2002
aan
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 nieuwe berichten