5 Replies - 11108 Views - Last Post: 18 March 2013 - 01:33 PM Rate Topic: -----

#1 nilesh7136  Icon User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 120
  • Joined: 03-January 13

do not display duplicate value

Posted 18 March 2013 - 11:00 AM

Hello There,,

i have a created an application, is it for price listing, automatically list down the price of Particular Brand, now i have a combobox, in the combobox i have fetched value from the database, there is a multiple value in multiple form, but i dont want to display duplicate, so is there any idea for that??
Just Display only one Time in Combobox::
Ex:
Brand Size Price
Soni 21 10000
Videocon 21 20000
Soni 22 25000

There two time Soni, so in combobox its display two time, but i want only one time display...
Code ::
Dim da As New SqlDataAdapter
        Dim ds As New DataSet
        Dim str As String = ("SELECT Brand FROM tblHosePriceList ORDER BY Brand")
        da.SelectCommand = New SqlCommand(str, conn)
        da.Fill(ds)
        comboHoseBrand.ValueMember = "ID"
        comboHoseBrand.DisplayMember = "Brand"
        comboHoseBrand.DataSource = ds.Tables(0)


Thanks,,
@Nilesh

Is This A Good Question/Topic? 0
  • +

Replies To: do not display duplicate value

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8401
  • View blog
  • Posts: 31,266
  • Joined: 12-June 08

Re: do not display duplicate value

Posted 18 March 2013 - 11:02 AM

You want to use 'DISTINCT'.
Was This Post Helpful? 1
  • +
  • -

#3 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3637
  • View blog
  • Posts: 5,766
  • Joined: 08-June 10

Re: do not display duplicate value

Posted 18 March 2013 - 11:14 AM

Depending on the database structure, you may also want to separate the brand names out of that table. Ideally there would be a "brands" table listing all the brands, which would then be referenced in the price list table to link each item to it's brand. Something like:
Table: brands
+----+----------+
| id | name     |
+---------------+
|  1 | Soni     |
|  2 | Videocon |
+----+----------+

Table: price_list
+----+----------+------+-------+
| id | brand_id | size | price |
+----+----------+------+-------+
|  1 |        1 |   21 | 10000 |
|  2 |        2 |   21 | 20000 |
|  3 |        1 |   22 | 25000 |
+----+----------+------+-------+


Was This Post Helpful? 1
  • +
  • -

#4 nilesh7136  Icon User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 120
  • Joined: 03-January 13

Re: do not display duplicate value

Posted 18 March 2013 - 11:22 AM

View Postmodi123_1, on 18 March 2013 - 11:02 AM, said:

You want to use 'DISTINCT'.

Can you Explain Me??
How to write query Using "DISTINCT"...??


@nilesh
Was This Post Helpful? 0
  • +
  • -

#5 nilesh7136  Icon User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 120
  • Joined: 03-January 13

Re: do not display duplicate value

Posted 18 March 2013 - 11:28 AM

View Postmodi123_1, on 18 March 2013 - 11:02 AM, said:

You want to use 'DISTINCT'.

Ohh Thanks Dear, Its Done, i have write "SELECT DISTINCT Size FROM tblHosePriceList ORDER BY Size", its work,

Thanks Again
@nilesh :)
Was This Post Helpful? 0
  • +
  • -

#6 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 5960
  • View blog
  • Posts: 23,238
  • Joined: 23-August 08

Re: do not display duplicate value

Posted 18 March 2013 - 01:33 PM

And this is posted in PHP, WHY exactly?

I'll move this to Databases instead.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1