C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




filter table at runtime from dataset and store it in datatable in c#


Posted Date: 07 Jul 2008    Resource Type: Code Snippets    Category: Databinding
Author: Sujit KumarMember Level: Diamond    
Rating: Points: 10



hi,

In this article I am filtering data from dataset and store it in different different table.

//connect to sql
con = new SqlConnection("Data Source=sujitkumar\\sqlexpress;Initial Catalog=pubs;Integrated Security=SSPI");
//in this line I have filled up dataset with two table, in first table all records are comming and in second table only unique id are coming from database.
String query = "select * from student;select distinct(id) from student";
da = new SqlDataAdapter(query, con);
da.Fill(ds);
//here I filled up different different table with unique id.
int count = ds.Tables[1].Rows.Count-1;
for (int i = 0; i <= count; i++)
{
DataView dv = ds.Tables[0].DefaultView;
dv.RowFilter = "id=" + ds.Tables[1].Rows[i][0];

DataTable dt = new DataTable();
dt=dv.ToTable(i.ToString());
ds.Tables.Add(dt);
}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Filter data from dataset  .  Datatable  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: ASP.NET DataList control with Next and Previous Buttons
Previous Resource: Enable and Disable a Control by Binding to another Control
Return to Discussion Resource Index
Post New Resource
Category: Databinding


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use