R
Rob W via DotNetMonster.com
Hi
I've created a datarelation between two tables in a dataset which works fine.
What I need to be able to handle is if there are entries in the child table
that don't match those in the parent then ignore them (the children).
In the code below if no records match in the custSQL query then the
datarelation will fail...
Any ideas would be great.
Dim custSQL As String = " Select distinct(a.retail_customer_Id), a.
retailer_id, Forename, Surname" & _
" from web_contact_history a, web_customers b
" & _
" where a.retail_customer_id = b.
retail_customer_id " & _
" and a.retailer_id = " & rtID & _
" and source_system_id = 'CVO' " & _
" and list_id = " & cvoID & _
" order by a.retail_customer_id "
Dim vehSQL As String = " select retail_customer_id, Vin, model,
cvo_retailer_id " & _
" from web_contact_history " & _
" where retailer_id = " & rtID & _
" and source_system_id = 'CVO' " & _
" and list_id = " & cvoID & _
" order by retail_customer_id "
Dim orphDS As DataSet = New DataSet
Dim rlConn As New OleDbConnection(connDB)
rlConn.Open()
Dim custDA As OleDbDataAdapter = New OleDbDataAdapter(custSQL, rlConn)
custDA.Fill(orphDS, "Customers")
Dim vehDA As OleDbDataAdapter = New OleDbDataAdapter(vehSQL, rlConn)
vehDA.Fill(orphDS, "Vehicles")
Dim orphDR_cust2veh = New DataRelation("cust2veh", orphDS.Tables
("Customers").Columns("retail_customer_id"), orphDS.Tables("Vehicles").
Columns("retail_customer_id"))
orphDS.Relations.Add(orphDR_cust2veh)
I've created a datarelation between two tables in a dataset which works fine.
What I need to be able to handle is if there are entries in the child table
that don't match those in the parent then ignore them (the children).
In the code below if no records match in the custSQL query then the
datarelation will fail...
Any ideas would be great.
Dim custSQL As String = " Select distinct(a.retail_customer_Id), a.
retailer_id, Forename, Surname" & _
" from web_contact_history a, web_customers b
" & _
" where a.retail_customer_id = b.
retail_customer_id " & _
" and a.retailer_id = " & rtID & _
" and source_system_id = 'CVO' " & _
" and list_id = " & cvoID & _
" order by a.retail_customer_id "
Dim vehSQL As String = " select retail_customer_id, Vin, model,
cvo_retailer_id " & _
" from web_contact_history " & _
" where retailer_id = " & rtID & _
" and source_system_id = 'CVO' " & _
" and list_id = " & cvoID & _
" order by retail_customer_id "
Dim orphDS As DataSet = New DataSet
Dim rlConn As New OleDbConnection(connDB)
rlConn.Open()
Dim custDA As OleDbDataAdapter = New OleDbDataAdapter(custSQL, rlConn)
custDA.Fill(orphDS, "Customers")
Dim vehDA As OleDbDataAdapter = New OleDbDataAdapter(vehSQL, rlConn)
vehDA.Fill(orphDS, "Vehicles")
Dim orphDR_cust2veh = New DataRelation("cust2veh", orphDS.Tables
("Customers").Columns("retail_customer_id"), orphDS.Tables("Vehicles").
Columns("retail_customer_id"))
orphDS.Relations.Add(orphDR_cust2veh)