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 !






How to Create Relations in Data Set using ADO.NET


Posted Date: 15 Sep 2008    Resource Type: Code Snippets    Category: ADO.NET

Posted By: Satyanarayan SushilKumar Bajoria       Member Level: Diamond
Rating:     Points: 10



Hi,

This code will show how to create relations in dataset using ADO.NET


using System.Data.SQLClient;


SQLConnection con=new SQLConnection("Your connection string");

SQLDataAdapter ad1;
SQLDataAdapter ad2;

DataSet ds=new DataSet();
DataRelation dr;

private void button1_click(object sender,EventArgs e)
{
ad1=new SQLDataAdapter("Select * from dept",con);
ad2=new SQLDataAdapter("select * from emp",con);
ad1.Fill(ds'"d");
ad2.Fill(ds,"e";
DataColumn pk=ds.Tables["d"].Columns["deptno"];
DataColumn fk=ds.Tables["e"].Columns["deptno"];
dr=new DataRelation("rel",pk,fk);
ds.Relations.Add(dr);
DataGrid1.DataSource=ds;

}

Regards
S.S.Bajoria




Responses


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

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Relation in DataSet  .  

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: How to use DataRelation in ADO.NET
Previous Resource: Connectivity of SQL to C#
Return to Discussion Resource Index
Post New Resource
Category: ADO.NET


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

conference call definitions

Contact Us    Privacy Policy    Terms Of Use