从vba中的查询获取字段描述

我正在开发一个函数来从查询中获取数据。 我想同时具有字段名称(来自数据库)和我的数据之前的字段说明。 我发现如何得到字段名称,但我没有find一个方法来获得描述,有人可以帮助我吗?

这是我现在的代码来获取字段名称(以及我如何获得描述评论):

'-Get the table's data Set rs = con.Execute("SELECT * FROM " & Sh.name) '-Set the name of the fields Dim TheCells As range Set TheCells = Sh.range("A2") For i = 0 To rs.Fields.Count - 1 TheCells.Offset(0, i).Value = rs.Fields(i).name 'TheCells.Offset(1, i).Value = rs.Fields(i).Properties("Description").Value Next i 

您可以使用ADOX来获取列的属性。

 Sub GetFieldDesc() Dim axCat As ADOX.Catalog Dim axTbl As ADOX.Table Dim adCon As ADODB.Connection Dim axProp As ADOX.Property 'Create an ado connection Set adCon = New ADODB.Connection adCon.Open sCON 'Point the adox catalog to that connection Set axCat = New ADOX.Catalog Set axCat.ActiveConnection = adCon 'Pick your table Set axTbl = axCat.Tables("tblCurrentPriceDate") Debug.Print axTbl.Columns(0).Properties("Description").Value End Sub 

设置对ActiveX Data ObjectsADO Ext. xx for DLL and Security的引用ADO Ext. xx for DLL and Security ADO Ext. xx for DLL and Security

我没有find任何方法从logging集中获取描述。 我发现的是从数据库中的属性获取描述的方法 – 基本上运行另一个查询来获取描述。 如何编写查询:

SQL Server

IBM