the result of the query inserted in an array/list with distinction of 2 columns.? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

the result of the query inserted in an array/list with distinction of 2 columns.?

reppelzreppelz PhilippinesPosts: 3Member
edited January 2014 in C#

ex. A 01/01/2011

B 01/01/2011

C 01/01/2011

D 01/01/2011

A 01/02/2011

B 01/02/2011

D 01/02/2011

A 01/03/2011

D 01/03/2011

The query were planning to use ?

SELECT DISTINCT Alphabets, dateReceive FROM database ORDER BY Alphabets

using List

Our expected output


Source code:

using (var conn = new SqlConnection("Data Source=SERV-PC\MSQLSERVER;Initial Catalog=MyDatabase;Integrated Security=True")) {

            using (var cmd = new SqlCommand())
                cmd.Connection = conn;
                cmd.CommandText = "SELECT DISTINCT [ColumnA], [DateReceive] FROM [MyDatabase].[dbo].[dummy] WHERE [ColumnA]=@loca  AND [DateReceive] BETWEEN '01/01/2013' and '01/07/2013' ";
                cmd.Parameters.AddWithValue("@loca", DropDownList1.SelectedValue.ToString());
                using (var reader = cmd.ExecuteReader())
                    while (reader.Read())

                        var tmp = reader["ColumnA"];
                        if (tmp != DBNull.Value)


hope anyone here can help us thanks

Sign In or Register to comment.