p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > .NET > Other .NET > ADO.NET
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 6th, 2009, 02:17 PM
Authorized User
Points: 64, Level: 1
Points: 64, Level: 1 Points: 64, Level: 1 Points: 64, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2007
Location: , , .
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
Default 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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old May 6th, 2009, 02:37 PM
Friend of Wrox
Points: 6,570, Level: 34
Points: 6,570, Level: 34 Points: 6,570, Level: 34 Points: 6,570, Level: 34
Activity: 42%
Activity: 42% Activity: 42% Activity: 42%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,000
Thanks: 5
Thanked 37 Times in 36 Posts
Send a message via MSN to gbianchi
Default

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.
================================================== =========
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
The Following User Says Thank You to gbianchi For This Useful Post:
akssmv (May 7th, 2009)
  #3 (permalink)  
Old May 7th, 2009, 02:04 PM
Authorized User
Points: 64, Level: 1
Points: 64, Level: 1 Points: 64, Level: 1 Points: 64, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2007
Location: , , .
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
Default

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old May 8th, 2009, 12:46 AM
Friend of Wrox
Points: 741, Level: 10
Points: 741, Level: 10 Points: 741, Level: 10 Points: 741, Level: 10
Activity: 2%
Activity: 2% Activity: 2% Activity: 2%
 
Join Date: May 2005
Location: OKC, OK, USA.
Posts: 211
Thanks: 1
Thanked 7 Times in 7 Posts
Default

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
The Following User Says Thank You to peace95 For This Useful Post:
akssmv (May 8th, 2009)
  #5 (permalink)  
Old May 8th, 2009, 10:19 AM
Authorized User
Points: 64, Level: 1
Points: 64, Level: 1 Points: 64, Level: 1 Points: 64, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2007
Location: , , .
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
Default

i will try it and let you know, thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Form Data Will Not Display When I Click On Display Button sprdave BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3 7 March 13th, 2009 12:28 AM
Using windows controls in C# cool_hari C# 1 June 22nd, 2006 12:22 PM
Windows Custom Controls bmains VB.NET 0 December 21st, 2005 12:17 PM
Display data into windows explorer din_porwal Pro VB.NET 2002/2003 0 August 26th, 2004 03:09 AM
Windows XP controls sangata VS.NET 2002/2003 8 April 12th, 2004 12:31 PM



All times are GMT -4. The time now is 10:52 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc