如下代碼演示如何使用 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