16,553
社区成员
发帖
与我相关
我的任务
分享
'引用了COM+ Services Type Library,Microsoft ActiveX Data Objects 2.8 Library,Microsoft ADO Ext. 2.8 for DDL and Security,Microsoft DAO 3.6 Object Library
Function ChengTableFieldPro_ADO()
Dim MyTableName As String
Dim MyFieldName As String
Dim GetFieldDesc_ADO
MyTableName = "testTable"
MyFieldName = "testField"
Dim MyDB As New ADOX.Catalog
Dim MyTable As ADOX.Table
Dim MyField As ADOX.Column
On Error GoTo Err_GetFieldDescription
MyDB.ActiveConnection = "telepara"
Set MyTable = MyDB.Tables(MyTableName)
Dim pro As ADODB.Property
For Each pro In MyTable.Columns(MyFieldName).Properties
Debug.Print pro.Name & " : " & pro.Value & " ---- type : " & pro.Type
Next
With MyTable.Columns(MyFieldName)
.Properties("Jet OLEDB:Allow Zero Length") = True '允许空
.Properties("default") = "默默默默认认认认" '默认值
End With
Set MyDB = Nothing
Bye_GetFieldDescription:
Exit Function
Err_GetFieldDescription:
Beep
Debug.Print Err.Description
MsgBox Err.Description, vbExclamation
GetFieldDescription = Null
Resume Bye_GetFieldDescription
End Function
alter table alter column 字段 null 是没用的