S
steve
Hello,
I have been trying to populate 2 or more controls from two *different*
(related) tables for the last week without success.
My latest try is: 2 simple SELECT statements in 2 adapters that populate the
*same* dataset and then i define a relation among the two tables.
SIMPLE !
Everything works fine but the controls from different tables are NOT
synchronised.
Am I doing something wrong or this is the wrong way altogether to attack
this problem?
I *also* tried to create a "complete" SELECT statement and pass the result
in the dataset with no success either.
Can anyone help? I know its very easy but i cant see what is wrong with my
code.
(Obviously i left out connection string etc. since everything else is
working)
And I am NOT asking for DataGrids!!!!!! this is easy. it worked. and i could
see where every column was coming from.
I am interested in labels, textboxes and droplists.
Thanx in advance
-steve
-----------------------------------------------------------------------
Dim strSelect1 As String = " SELECT * FROM tblCustomers"
Dim strSelect2 As String = " SELECT * FROM tblOrders "
Dim DS As New DataSet
'SQL Data Adapter
Dim DBAdapter1 As OleDbDataAdapter = New OleDbDataAdapter(strSelect1,
DBConnection)
DBAdapter1.Fill(DS, "tblCustomers")
Dim DBAdapter2 As OleDbDataAdapter = New OleDbDataAdapter(strSelect2,
DBConnection)
DBAdapter2.Fill(DS, "tblOrders")
DS.Relations.Add("CustomerOrders", _
DS.Tables("tblCustomers").Columns("CustomerID"), _
DS.Tables("tblOrders").Columns("CustomerID"))
'****** populate controls ***************
cmb1.DataSource = DS
cmb1.DisplayMember = "tblCustomers.CustomerID"
cmb2.DataSource = DS
cmb2.DisplayMember = "tblOrders.OrderID"
lbl1.DataBindings.Clear()
lbl1.DataBindings.Add("text", DS, "tblOrders.Date")
'*********************
I have been trying to populate 2 or more controls from two *different*
(related) tables for the last week without success.
My latest try is: 2 simple SELECT statements in 2 adapters that populate the
*same* dataset and then i define a relation among the two tables.
SIMPLE !
Everything works fine but the controls from different tables are NOT
synchronised.
Am I doing something wrong or this is the wrong way altogether to attack
this problem?
I *also* tried to create a "complete" SELECT statement and pass the result
in the dataset with no success either.
Can anyone help? I know its very easy but i cant see what is wrong with my
code.
(Obviously i left out connection string etc. since everything else is
working)
And I am NOT asking for DataGrids!!!!!! this is easy. it worked. and i could
see where every column was coming from.
I am interested in labels, textboxes and droplists.
Thanx in advance
-steve
-----------------------------------------------------------------------
Dim strSelect1 As String = " SELECT * FROM tblCustomers"
Dim strSelect2 As String = " SELECT * FROM tblOrders "
Dim DS As New DataSet
'SQL Data Adapter
Dim DBAdapter1 As OleDbDataAdapter = New OleDbDataAdapter(strSelect1,
DBConnection)
DBAdapter1.Fill(DS, "tblCustomers")
Dim DBAdapter2 As OleDbDataAdapter = New OleDbDataAdapter(strSelect2,
DBConnection)
DBAdapter2.Fill(DS, "tblOrders")
DS.Relations.Add("CustomerOrders", _
DS.Tables("tblCustomers").Columns("CustomerID"), _
DS.Tables("tblOrders").Columns("CustomerID"))
'****** populate controls ***************
cmb1.DataSource = DS
cmb1.DisplayMember = "tblCustomers.CustomerID"
cmb2.DataSource = DS
cmb2.DisplayMember = "tblOrders.OrderID"
lbl1.DataBindings.Clear()
lbl1.DataBindings.Add("text", DS, "tblOrders.Date")
'*********************