K
Kay
Hi all,
I have populated a dataset with several tables, say - Roster, Agent and few
more . The dataset is used to populated a listview with some shift info..
I think I'm sucessfully created a relationship in the dataset. In the
Roster table there's an "AgentKey" which can be linked to the Agent table.
What I'm tryting to do is, while I'm looping thru the dataset, I want to
show the Name of an Agent in the listview from the Agent table.
I have a look on the help or internet, the answer I found is I have to loop
thru the Agent table... since there may be couple hundreds Roster record may
be returned, and I also need to show several other columns in the same
manner, I'm worry the process may be pretty slow.
So I'm wondering is there a better way to do it?
Here's my code:
Dim daRoster, daAgent As SqlDataAdapter
Dim rowRoster As DataRow
daRoster = New SqlDataAdapter(sSQL, Conn)
daAgent = New SqlDataAdapter("Select Agent_Key, Name, from Agent", Conn)
dsRoster.Relations.Add("AgttoR",
dsRoster.Tables("Agent").Columns("Agent_Key"), dsRoster.Tables
("Roster").Columns("Agent_Key"))
For Each rowRoster In dsRoster.Tables("Roster").Rows
itmx = New ListViewItem
itmx.Text = rowRoster("Agent_Roster_Key")
itmx.SubItems.Add(rowRoster("Name") '**** this doesn't
work ...
lvwRoster.Items.Add(itmx)
Next
Thanks~
Kay
I have populated a dataset with several tables, say - Roster, Agent and few
more . The dataset is used to populated a listview with some shift info..
I think I'm sucessfully created a relationship in the dataset. In the
Roster table there's an "AgentKey" which can be linked to the Agent table.
What I'm tryting to do is, while I'm looping thru the dataset, I want to
show the Name of an Agent in the listview from the Agent table.
I have a look on the help or internet, the answer I found is I have to loop
thru the Agent table... since there may be couple hundreds Roster record may
be returned, and I also need to show several other columns in the same
manner, I'm worry the process may be pretty slow.
So I'm wondering is there a better way to do it?
Here's my code:
Dim daRoster, daAgent As SqlDataAdapter
Dim rowRoster As DataRow
daRoster = New SqlDataAdapter(sSQL, Conn)
daAgent = New SqlDataAdapter("Select Agent_Key, Name, from Agent", Conn)
dsRoster.Relations.Add("AgttoR",
dsRoster.Tables("Agent").Columns("Agent_Key"), dsRoster.Tables
("Roster").Columns("Agent_Key"))
For Each rowRoster In dsRoster.Tables("Roster").Rows
itmx = New ListViewItem
itmx.Text = rowRoster("Agent_Roster_Key")
itmx.SubItems.Add(rowRoster("Name") '**** this doesn't
work ...
lvwRoster.Items.Add(itmx)
Next
Thanks~
Kay