How to get distinct Data from Dataset ( or) select distinct from dataset.

In some scenario select distinct data from the Dataset. Dataset provide an option to get distinct data from the dataset. I have database connection to connect my local database.

  SqlDataAdapter da = new SqlDataAdapter(“select empolyeename,Department,salary from employees inner
join department on  employees.deptid=department.deptid”
, con);

DataSet ds = new DataSet();


After fill the dataset we want to select distinct department from the dataset.For this use the DefaultView.ToTable()


GridView1.DataSource= dv.ToTable(true, “Department”);


This entry was posted in Articles and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s