|
以下是一段创建动态数据库的代码,创建后所有字段必须是非空,怎样才能让新添加的字段可以为空呢。请高手指点!
-
- Sub CreateAccessTable2() '创建数据库表
- Dim mycat As New ADOX.Catalog
- Dim mytable As New ADOX.Table
- If Dir(ThisWorkbook.Path & "\mydatabase.mdb") = "" Then
- mycat.Create "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;" & _
- "Data Source=" & ThisWorkbook.Path & "\mydatabase.mdb"
- End If
- mycat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
- ThisWorkbook.Path & "\mydatabase.mdb" '创建access数据库成功
- mytable.Name = "测试表a"
- mycat.Tables.Append mytable
- With mytable.Columns
- .Append "name", adVarWChar, 30
- .Append "birthday", adDate
- .Append "age", adInteger
- .Append "married", adBoolean
- End With
- mycat.Tables.Refresh
- Set mytable = Nothing
- Set mycat.ActiveConnection = Nothing
- End Sub
复制代码
[ 本帖最后由 老伙计2008 于 2010-4-4 00:22 编辑 ] |
|