帮我译vb为c#

xhjdxx 2003-07-29 06:08:48
Private Sub CreateRelation()
' Get the DataColumn objects from two DataTable objects in a DataSet.
Dim parentCols() As DataColumn
Dim childCols() As DataColumn
' Code to get the DataSet not shown here.
parentCols(0) = DataSet1.Tables("Customers").Columns("CustID")
parentCols(1) = DataSet1.Tables("Customers").Columns("OrdID")

childCols(0) = DataSet1.Tables("Orders").Columns("CustID")
childCols(1) = DataSet1.Tables("Orders").Columns("OrdID")
' Create DataRelation.
Dim CustOrderRel As DataRelation
CustOrderRel = New DataRelation("CustomersOrders", parentCols, childCols)
' Add the relation to the DataSet.
DataSet1.Relations.Add(CustOrderRel)
End Sub
...全文
16 2 打赏 收藏 举报
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
雪狼1234567 2003-07-29
  • 打赏
  • 举报
回复
如下:
DataColumn [] parentCols = new DataColumn[2];
parentCols[0] = DataSet1.Tables("Customers").Columns("CustID")
parentCols[1] = DataSet1.Tables("Customers").Columns("CustID")
DataColumn [] childCols = new DataColumn[2];
dcDetail[0] = DataSet1.Tables("Orders").Columns("CustID")
dcDetail[1] = DataSet1.Tables("Orders").Columns("CustID")
DataRelation CustOrderRel = new DataRelation("CustomersOrders", parentCols, childCols)
DataSet1.Relations.Add(CustOrderRel)
TheAres 2003-07-29
  • 打赏
  • 举报
回复
除了函数,把()换成[]就基本可以了。

发帖
C#

10.8w+

社区成员

.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
帖子事件
创建了帖子
2003-07-29 06:08
社区公告

让您成为最强悍的C#开发者