I used the following code to select unique values from the database
myCommand = New SqlCommand("SELECT DISCTINCT Visitor, BookCode FROM tblBook", myConnection)
myAdapter = New SqlDataAdapter(myCommand)
myAdapter.Fill(myDataSet, "tblBook")
cboAuthor.DataSource = myDataSet.Tables(0)
cboAuthor.DisplayMember = "Author"
cboAuthor.ValueMember = "BookCode"
And it does not retrieve the unique values, it remains the same. But if I use only SELECT DISTINCT Author FROM tblBook it works fine.
Please help.
SELECT DISTINCTwill ensure that no duplicate records are returned in the result set.Therefore if you only put SELECT DISTINCT Author, you will get a list of unique authors.
Putting
SELECT DISTINCT Author, Visitor, BookCodemay return duplicate authors, with different visitor or bookcode.