以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  如何实现同时自动获得所有数据表、表间关联的表名称和列名称?  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=29833)

--  作者:lipiti
--  发布时间:2013/3/14 16:19:00
--  如何实现同时自动获得所有数据表、表间关联的表名称和列名称?
自动获得所有数据表的表名称和列名称,代码如下:

For Each dt As DataTable In DataTables
For Each dc As DataCol In dt.DataCols
Dim dr As DataRow = DataTables("表列" ).Find( "表名 = \'" & dt. Name & "\' And 列名 = \'" & dc.Name & "\'")
If dr Is Nothing Then
dr = DataTables ("表列"). AddNew()
dr("表名" ) = dt. Name
dr("列名" ) = dc. Name
End If
Next
Next

以上代码不能实现自动获得所有表间关联的表名称和列名称
根据

Relations表示关联集合,可以获得指定名称的关联,例如:

Dim re As Relation
re = Relations(
"ab"
)


狐狸爸爸,帮忙修改一下代码,可以实现同时自动获得所有数据表、表间关联的表名称和列名称,谢谢!


--  作者:lipiti
--  发布时间:2013/3/14 17:53:00
--  
非常感谢!庞工对我们菜鸟的耐心指导!已经解决了!