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.Relati ons.Add("AgttoR ",
dsRoster.Tables ("Agent").Colum ns("Agent_Key") , dsRoster.Tables
("Roster").Colu mns("Agent_Key" ))
For Each rowRoster In dsRoster.Tables ("Roster").R ows
itmx = New ListViewItem
itmx.Text = rowRoster("Agen t_Roster_Key")
itmx.SubItems.A dd(rowRoster("N ame") '**** this doesn't
work ...
lvwRoster.Items .Add(itmx)
Next
Thanks~
Kay 11 6652
Here is one similar piece of code I have from the past (almost the
same). The child Grids automatically update with child table
information when you move the cursor on parent records. Also the parent
grid expands into related child lists.
Dim ds As DataSet = New DataSet
ds.Clear()
adpCustomers.Fi ll(ds, "Customers" )
adpOrders.Fill( ds, "Orders")
adpOrderDetails .Fill(ds, "Order Details")
ds.Relations.Ad d("CustomersToO rders", _
ds.Tables("Cust omers").Columns ("CustomerID "), _
ds.Tables("Orde rs").Columns("C ustomerID"))
ds.Relations.Ad d("OrdersToOrde rDetails", _
ds.Tables("Orde rs").Columns("O rderID"), _
ds.Tables("Orde r Details").Colum ns("OrderID"))
dgCustomers.Dat aSource = ds
dgCustomers.Dat aMember = "Customers"
dgOrders.DataSo urce = ds
dgOrders.DataMe mber = "Customers.Cust omersToOrders"
dgOrderDetails. DataSource = ds
dgOrderDetails. DataMember =
"Customers.Cust omersToOrders.O rdersToOrderDet ails"
Hope it's what you are looking for.
Hi Bill,
Thanks for your help~ the first bit of your code is very similar to mine but
I need to populate the data into a listview and the each record will be in
one row, rather than in hierarchal, for example:
Agent Name/Shift Date/Shift Start/Shift End
Kay/01-11-2005/10.00/18.00
Agent Name is linked to Agent table(child), the rest are Roster
table(parent). And I don't know how to get the Agent Name(child table) from
a dataset.....
If you need more info please let me know~
T.I.A.
Kay
<bi*********@gm ail.com> wrote in message
news:11******** **************@ g47g2000cwa.goo glegroups.com.. . Here is one similar piece of code I have from the past (almost the same). The child Grids automatically update with child table information when you move the cursor on parent records. Also the parent grid expands into related child lists.
Dim ds As DataSet = New DataSet ds.Clear() adpCustomers.Fi ll(ds, "Customers" ) adpOrders.Fill( ds, "Orders") adpOrderDetails .Fill(ds, "Order Details")
ds.Relations.Ad d("CustomersToO rders", _ ds.Tables("Cust omers").Columns ("CustomerID "), _ ds.Tables("Orde rs").Columns("C ustomerID"))
ds.Relations.Ad d("OrdersToOrde rDetails", _ ds.Tables("Orde rs").Columns("O rderID"), _ ds.Tables("Orde r Details").Colum ns("OrderID"))
dgCustomers.Dat aSource = ds dgCustomers.Dat aMember = "Customers"
dgOrders.DataSo urce = ds dgOrders.DataMe mber = "Customers.Cust omersToOrders"
dgOrderDetails. DataSource = ds dgOrderDetails. DataMember = "Customers.Cust omersToOrders.O rdersToOrderDet ails"
Hope it's what you are looking for.
Kay,
I first did not see that Bill gave you the correct answer.And now I see he
does not need the sample I have given him in a latter post.
What I wanted to write to you was, that you would benefit not using the
listview for data-objects. (System.data). In that is the DataGrid and the
DataGridView optimalized. The listview will give you only as mostly all who
tried this sooner or later a lot of trouble.
However if you persist, while I think that even the TreeView can be better
about what you wrote to Bill.
You can get from every datarow with relations its childs and it parent if
those exist.
Just my thought,
Cor
Hi Cor,
I though of datagrid before but user must click on a link to see the child's
data - since I simply want to show the Agent's name (instead of AgentKey),
it seems listview may do the job - if I can retrive the data from a child
table, let me explain :
In roster table it has all the shift info like AgentID/date/time/campaign
etc, so a roster record in the listview will looks like that
Agent Name/Shift Date/Shift Start/Shift End
Kay/01-11-2005/10.00/18.00
They're in one row although the Agent name is coming from a different table.
I've created a relation in a dataset, after I done a bit more reseach I
found the GetChildRows method, however I need to loop thru the whole Agent
table to get the name. I'm worring on the performance coz I need to link to
3 different table to display one roster record, and there may hundreds or
roster records in the listview...
Do you think I'm on the right track?
Thanks!
Kay
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:O4******** ******@tk2msftn gp13.phx.gbl... Kay,
I first did not see that Bill gave you the correct answer.And now I see he does not need the sample I have given him in a latter post.
What I wanted to write to you was, that you would benefit not using the listview for data-objects. (System.data). In that is the DataGrid and the DataGridView optimalized. The listview will give you only as mostly all who tried this sooner or later a lot of trouble.
However if you persist, while I think that even the TreeView can be better about what you wrote to Bill.
You can get from every datarow with relations its childs and it parent if those exist.
Just my thought,
Cor
Kay,
I tried it using completely the designer.
I opened the data -> datasource and selected in that wizard the NorthWind
database with the tables customers and customerorders.
Than I dragged a datagridview on my form
I set the properties datasource of that (opening that property until I had
by clicking the plus buttons the order table).
After that I opened the edit columns with the link at the bottom. I choise
the idcustomercolum n and said that it was a combobox. I set for that the
datasource to the customer table and set as well the displaymember to
customername and the valuemember to customerid
Than I started debug and it was running showing a nice datagridview with a
combobox with the names of the customers in it, that I could select to
change those.
I hope this helps,
Cor
Kay,
This was an answer to Bill, I has set it apart to try to answer it later. As
I did with yours, however added it to the wrong messagthread.
Sorry
Cor
Kay,
Don't be afraid for looping that is done so many times behind the scene and
you don't see it.
Another approach (I did not test it) is setting an extra columns to your
table "Author"
Than you can use in that an expression to the parent. http://msdn.microsoft.com/library/de...ionColumns.asp
Than use the expression http://msdn.microsoft.com/library/de...ssionTopic.asp
And than this part in it.
PARENT/CHILD RELATION REFERENCING
A parent table may be referenced in an expression by prepending the column
name with Parent. For example, the Parent.Price references the parent
table's column named Price.
Than you can use that datatable to use in a datagrid, and with nice
columnstyles you get in my opinion a nicer view on it than with a listview.
I would give it a try in your case.
Cor
"Kay" <kk@micxsoft.co m> schreef in bericht
news:Ou******** ******@TK2MSFTN GP11.phx.gbl... Hi Cor,
I though of datagrid before but user must click on a link to see the child's data - since I simply want to show the Agent's name (instead of AgentKey), it seems listview may do the job - if I can retrive the data from a child table, let me explain :
In roster table it has all the shift info like AgentID/date/time/campaign etc, so a roster record in the listview will looks like that
Agent Name/Shift Date/Shift Start/Shift End Kay/01-11-2005/10.00/18.00
They're in one row although the Agent name is coming from a different table. I've created a relation in a dataset, after I done a bit more reseach I found the GetChildRows method, however I need to loop thru the whole Agent table to get the name. I'm worring on the performance coz I need to link to 3 different table to display one roster record, and there may hundreds or roster records in the listview...
Do you think I'm on the right track?
Thanks! Kay
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message news:O4******** ******@tk2msftn gp13.phx.gbl... Kay,
I first did not see that Bill gave you the correct answer.And now I see he does not need the sample I have given him in a latter post.
What I wanted to write to you was, that you would benefit not using the listview for data-objects. (System.data). In that is the DataGrid and the DataGridView optimalized. The listview will give you only as mostly all who tried this sooner or later a lot of trouble.
However if you persist, while I think that even the TreeView can be better about what you wrote to Bill.
You can get from every datarow with relations its childs and it parent if those exist.
Just my thought,
Cor
Kay,
I made a sample from it, I thougth it works. http://www.vb-tips.com/default.aspx?...3-8a9529b2b38b
I hope this helps,
Cor
"Cor Ligthert [MVP]" <no************ @planet.nl> schreef in bericht
news:Of******** ******@TK2MSFTN GP11.phx.gbl... Kay,
Don't be afraid for looping that is done so many times behind the scene and you don't see it.
Another approach (I did not test it) is setting an extra columns to your table "Author"
Than you can use in that an expression to the parent.
http://msdn.microsoft.com/library/de...ionColumns.asp
Than use the expression http://msdn.microsoft.com/library/de...ssionTopic.asp
And than this part in it. PARENT/CHILD RELATION REFERENCING
A parent table may be referenced in an expression by prepending the column name with Parent. For example, the Parent.Price references the parent table's column named Price.
Than you can use that datatable to use in a datagrid, and with nice columnstyles you get in my opinion a nicer view on it than with a listview.
I would give it a try in your case.
Cor
"Kay" <kk@micxsoft.co m> schreef in bericht news:Ou******** ******@TK2MSFTN GP11.phx.gbl... Hi Cor,
I though of datagrid before but user must click on a link to see the child's data - since I simply want to show the Agent's name (instead of AgentKey), it seems listview may do the job - if I can retrive the data from a child table, let me explain :
In roster table it has all the shift info like AgentID/date/time/campaign etc, so a roster record in the listview will looks like that
Agent Name/Shift Date/Shift Start/Shift End Kay/01-11-2005/10.00/18.00
They're in one row although the Agent name is coming from a different table. I've created a relation in a dataset, after I done a bit more reseach I found the GetChildRows method, however I need to loop thru the whole Agent table to get the name. I'm worring on the performance coz I need to link to 3 different table to display one roster record, and there may hundreds or roster records in the listview...
Do you think I'm on the right track?
Thanks! Kay
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message news:O4******** ******@tk2msftn gp13.phx.gbl... Kay,
I first did not see that Bill gave you the correct answer.And now I see he does not need the sample I have given him in a latter post.
What I wanted to write to you was, that you would benefit not using the listview for data-objects. (System.data). In that is the DataGrid and the DataGridView optimalized. The listview will give you only as mostly all who tried this sooner or later a lot of trouble.
However if you persist, while I think that even the TreeView can be better about what you wrote to Bill.
You can get from every datarow with relations its childs and it parent if those exist.
Just my thought,
Cor
Hi Cor,
Just a quick reply & thanks for your info :D !! I'll try the datagrid and
listview see which one is better for my case. Coz there're other issues I
need to consider if I use datagrid.
Also a question... in your example:
DataGridView1.D ataSource = dt2
What is the > DataGridView1 < ?
Kay :)
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:u3******** ******@TK2MSFTN GP10.phx.gbl... Kay,
I made a sample from it, I thougth it works.
http://www.vb-tips.com/default.aspx?...3-8a9529b2b38b
I hope this helps,
Cor
"Cor Ligthert [MVP]" <no************ @planet.nl> schreef in bericht news:Of******** ******@TK2MSFTN GP11.phx.gbl... Kay,
Don't be afraid for looping that is done so many times behind the scene and you don't see it.
Another approach (I did not test it) is setting an extra columns to your table "Author"
Than you can use in that an expression to the parent.
http://msdn.microsoft.com/library/de...ionColumns.asp
Than use the expression http://msdn.microsoft.com/library/de...ssionTopic.asp
And than this part in it. PARENT/CHILD RELATION REFERENCING
A parent table may be referenced in an expression by prepending the column name with Parent. For example, the Parent.Price references the parent table's column named Price.
Than you can use that datatable to use in a datagrid, and with nice columnstyles you get in my opinion a nicer view on it than with a listview.
I would give it a try in your case.
Cor
"Kay" <kk@micxsoft.co m> schreef in bericht news:Ou******** ******@TK2MSFTN GP11.phx.gbl... Hi Cor,
I though of datagrid before but user must click on a link to see the child's data - since I simply want to show the Agent's name (instead of AgentKey), it seems listview may do the job - if I can retrive the data from a child table, let me explain :
In roster table it has all the shift info like AgentID/date/time/campaign etc, so a roster record in the listview will looks like that
Agent Name/Shift Date/Shift Start/Shift End Kay/01-11-2005/10.00/18.00
They're in one row although the Agent name is coming from a different table. I've created a relation in a dataset, after I done a bit more reseach I found the GetChildRows method, however I need to loop thru the whole Agent table to get the name. I'm worring on the performance coz I need to link to 3 different table to display one roster record, and there may hundreds or roster records in the listview...
Do you think I'm on the right track?
Thanks! Kay
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message news:O4******** ******@tk2msftn gp13.phx.gbl... Kay,
I first did not see that Bill gave you the correct answer.And now I see he does not need the sample I have given him in a latter post.
What I wanted to write to you was, that you would benefit not using the listview for data-objects. (System.data). In that is the DataGrid and the DataGridView optimalized. The listview will give you only as mostly all who tried this sooner or later a lot of trouble.
However if you persist, while I think that even the TreeView can be better about what you wrote to Bill.
You can get from every datarow with relations its childs and it parent if those exist.
Just my thought,
Cor
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Stephen Ritchie |
last post by:
I have a dataset that contains two tables - Parent and Child. The key of the
Parent is called ParentID and is an identity column in SQL Server. The key of
the Child is two columns called ParentID - foreign key defined as INT to
Parent table - and ChildID that in itself is an identity column. I have used
the designer to create a relationship...
|
by: Bill C. |
last post by:
Hi,
I've got a simple console app that just reads an XML file into a DataSet
then prints out a description of each table in the DataSet, including
column names and row values for each column. I'm getting some strange
results depending the input XML file I use. I was wondering if somebody
could help me understand what is going on or point...
|
by: Fleckman |
last post by:
I have a situation where I need to add rows to tables with a Parent-Child
relationship which presents a constraints violation when I reject the
changes. Here is the scenario:
I add a row to a Parent table which then causes a row to be added to the
Child table referencing the parent row. The Child table rows can be modified
by multiple...
|
by: Johann Blake |
last post by:
I have a dataset that contains a parent table and a child table. A
DataRelation exists between the two. I was under the impression from
reading the VS docs that when I filled the parent table, the child
table would be automatically filled with the child records. When I fill
the parent, I limit the table to only a single record, so that all the...
|
by: Kenny |
last post by:
Hello all, I've made a dataset by using the xsd tool in C#. In the xsd
schema, there are a few tables, each has its own primary key. And, I've made
relation between them.
After all things are done, I can use the dataset class generated to retrieve
data. The problem is that, when I try to delete a parent row (using
RemoveTABLERow method),...
| |
by: Geoff Jones |
last post by:
Hi
Can anybody help me with the following, hopefully simple, question?
I have a table which I've connected to a dataset. I wish to add a new column
to the beginning of the table
and to fill it with incremental values e.g. if the tables looks
like this:
23 56
|
by: Mr Newbie |
last post by:
HI People,
Thanks to all who helped me earlier on the subject of @@IDentity. However, I
seem to have hit another snagette!
My DataSet contains two tables from the SQL Server. lets say Master and
Details. The way I have it set up is that a relationship exists in the
DataSet between the two to force referential integrety etc.
I am now...
|
by: Tony Girgenti |
last post by:
Hello
I developed and tested a web application using VS.NET 2003, VB, .NET
Framework 1.1.4322, ASP.NET 1.1.4322 and IIS5.1. It uses a web form.
I tried doing this without any help, but i'm getting nowhere.
I want to create an XML schema (XSD) for a dataset/datatable using the XML
designer.
|
by: mike11d11 |
last post by:
My program has to tables in it. One is the Accounts table with all
personal information and then there is also my Memos table with all the
notes for each account. My program displays one record at a time for
each account in the dataset table. I now want to show only the notes
in the memo file that match with the Accounts table current...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |