[已解决]怎样在dataset中建立两表的关系。。
Private Sub TableRelation(ByVal RelationName As String, ByVal ParentTableName As String, ByVal ParentColu As String, ByVal childTableName As String, ByVal childColu As String)ds.Relations.Add(RelationName, ds.Tables(ParentTableName).Columns(ParentColu), ds.Tables(childTableName).Columns(childColu))
End Sub
Public Function test() As DataSet
RunselectSQL("select * from customers", "Cumtomers")
RunselectSQL("select * from Orders", "Orders")
RunselectSQL("select * from OrderDetails", "OrderDetails")
TableRelation("CustomersAndOrders", "Customers", "CustomerID", "Orders", "CustomerID")
Return ds
End Function
这是我的代码
RunselectSQL是从数据库中读取数据,存放在DATASET中。。。。
提示错误是 Object reference not set to an instance of an object.
[[italic] 本帖最后由 wuhongyao3 于 2007-12-20 10:26 编辑 [/italic]]