如下代码演示如何使用 ParentCatalog 属性,在将表追加到目录之前访问指定提供者的属性。
Sub SetAllowZeroLength()
Dim cnn As New ADODB.Connection
Dim cat As New ADOX.Catalog
Dim tbl As New ADOX.Table
Dim col As New ADOX.Column
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source= c:\Program Files\" & _
"Microsoft Office\Office\Samples\Northwind.mdb;"
Set cat.ActiveConnection = cnn
tbl.Name = "MyTable"
tbl.Columns.Append "Column1", adInteger
Set col.ParentCatalog = cat
col.Name = "Column2"
col.Type = adVarWChar
col.Properties("Jet OLEDB:Allow Zero Length") = True
tbl.Columns.Append col
cat.Tables.Append tbl
End Sub