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();

da.Fill(ds,“details”);


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”);

GridView1.DataBind();

Advertisements
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:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s