如何使用SQL在Access表中插入列的描述?
我做:
CREATE TABLE TAB_A (COLUMN1 TEXT(30), COLUMN2 REAL, PRIMARY KEY (COLUMN1)
但是如何为每列插入说明?
答案 0 :(得分:1)
您无法在SQL中执行此操作。
KB210314:ACC2000: How to Use ADO or DAO to Retrieve a Field's Description
我认为它的设置方式与检索方式相同:
Function SetFieldDesc_ADO(ByVal MyTableName As String, ByVal MyFieldName As String, ByVal Description As String)
Dim MyDB As New ADOX.Catalog
Dim MyTable As ADOX.Table
Dim MyField As ADOX.Column
On Error GoTo Err_SetFieldDescription
MyDB.ActiveConnection = CurrentProject.Connection
Set MyTable = MyDB.Tables(MyTableName)
MyTable.Columns(MyFieldName).Properties("Description").Value = Description
Set MyDB = Nothing
Bye_SetFieldDescription:
Exit Function
Err_SetFieldDescription:
MsgBox Err.Description, vbExclamation
Resume Bye_SetFieldDescription
End Function
答案 1 :(得分:0)
Dim col As ADOX.Column = New ADOX.Column
With col
.Name = name
.Type = type
.DefinedSize = size
.ParentCatalog = cat
.Properties("Description").Value = description
End With