DataGrids and DataRelations

I have a VB.NET WinForm application that implements a Datagrid. I know how to set DataRelations for simple relationships such as : Dim daCust As New SqlDataAdapter("Select * From Customers Where CustomerID Like 'A%'", moConn)
Dim daOrders As New SqlDataAdapter("Select * From Orders Where CustomerID Like 'A%'", moConn)
Dim ds As New DataSet
daCust.Fill(ds, "Cust")
daOrders.Fill(ds, "Orders")
'Build the relation between Orders and Customers.
ds.Relations.Add("CustOrd", ds.Tables!Cust.Columns!CustomerID, ds.Tables!Orders.Columns!CustomerID)
dgValues.DataSource = ds
dgValues.DataMember = "Cust"

But I have a more complex query I need to set the DataRelations for: SELECT CostCenter.CostCenter AS CostCentername,Product.Name as ProductName ,Vendor.Name as VendorName ,Alert.NotifyDate as AlertNotifyDate ,Alert.Message as AlertMessage ,Product.ProductId as ProductId ,Contract.ContractID AS ContractID FROM CostCenter, Product, Vendor, Alert, Contract WHERE Alert.ActiveIndicator = 1
AND CostCenter.CostCenterID = Contract.CostCenterid
AND Contract.ContractID = Product.ContractID
AND Product.ProductId = Alert.ProductId
AND Product.VendorId = Vendor.VendorId
AND DateDiff(day,Alert.NotifyDate,GetDate()) >= 0
ORDER BY CostCenter.Costcenter,Alert.NotifyDate ASC

I don't know how to even start this. Please help!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!