|
|
 |
| ADO.NET For discussion about ADO.NET. Topics such as question regarding the System.Data namespace are appropriate. Questions specific to a particular application should be posted in a forum specific to the application . |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ADO.NET section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

May 6th, 2009, 02:17 PM
|
|
Authorized User
|
|
Join Date: Jun 2007
Location: , , .
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
Regarding data display in windows controls
Hi
I have a windows form with a combobox and listbox.
I have a table name Categories with two columns Category and Subcategory.
Sample data
Category SubCategory
Breakfast Eggmuffin
Breakfast Sausage Muffin
Sandwich Hamburger
Sandwich Cheeseburger
I would like to display the Category in the combobox avoiding the duplicate rows.
Based on the selection of the Category in the combobox, i would like to display the subcategory column in the list box.
It would be nice if anyone could help me with this.
Thanks
Sathi
Last edited by akssmv : May 6th, 2009 at 02:24 PM.
|

May 6th, 2009, 02:37 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,000
Thanks: 5
Thanked 37 Times in 36 Posts
|
|
Hello..
Let's take aside that the table is bad constructed (Categories should be on another table, and this table should had only the id), You could solve your problem using a SELECT DISTINCT category FROM ...
__________________
HTH
Gonzalo
================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the proof.
================================================== =========
|
|
The Following User Says Thank You to gbianchi For This Useful Post:
|
|

May 7th, 2009, 02:04 PM
|
|
Authorized User
|
|
Join Date: Jun 2007
Location: , , .
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
Hi
Now I have two tables
1)
Categories
CategoryID --- PK
Category Name
2)
Subcategories
CategoryId----FK
SubCategory
I would like to display the category name from Categories table in combobox.
Based on the selection from the combobox corresponding subcategory from the Subcategories table( here Category id can be duplicate)in the listbox.
Would be nice if anyone could help me in this.
|

May 8th, 2009, 12:46 AM
|
|
Friend of Wrox
|
|
Join Date: May 2005
Location: OKC, OK, USA.
Posts: 211
Thanks: 1
Thanked 7 Times in 7 Posts
|
|
akssmv:
Re-structure the Sub-Category Object to the following:
SUBCATEGORY_TBL
SUBCATID PK number,
CATEGORYID FK number, /* Comment: Enforce FK Referential Constraint */
SUBCAT_NAME varchar (80)
Also include for Delete operation, to include Cascade Deletes.
Then use the table in you listbox with the following Query:
select DISTINCT a.CATEGORY_NAME, b.SUBCAT_NAME
from CATEGORY_TBL a, SUBCATEGORY_TBL b
where a.CATEGORYID = b.CATEGORYID
orderby b.CATEGORYID, b.SUBCATID
groupby b.CATEGORYID, b.SUBCATID
Hope this helps.
__________________
Disclaimer: The above comments are solely the opinion of one person and not to be construed as a directive or an incentive to commit fraudulent acts.
|
|
The Following User Says Thank You to peace95 For This Useful Post:
|
|

May 8th, 2009, 10:19 AM
|
|
Authorized User
|
|
Join Date: Jun 2007
Location: , , .
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
i will try it and let you know, thanks
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |