How to insert a column description into an Access table?

前端 未结 2 1296
隐瞒了意图╮
隐瞒了意图╮ 2021-01-15 09:10

How can I insert a description for a column in an Access table using SQL?

I do:

CREATE TABLE TAB_A (COLUMN1 TEXT(30), COLUMN2 REAL, PRIMARY KEY (COL         


        
相关标签:
2条回答
  • 2021-01-15 09:37

    You can't do it in SQL.

    KB210314: ACC2000: How to Use ADO or DAO to Retrieve a Field's Description

    I reckon that it can be set the same way that it can be retrieved:

    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
    
    0 讨论(0)
  • 2021-01-15 09:51
    Dim col As ADOX.Column = New ADOX.Column
    With col
      .Name = name
      .Type = type
      .DefinedSize = size
      .ParentCatalog = cat
      .Properties("Description").Value = description
    End With
    
    0 讨论(0)
提交回复
热议问题