Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO.Net - Populate dataset with sql server tables and relations

Status
Not open for further replies.

spangeman

Programmer
Oct 16, 2004
96
EU
Hi

Is there an easy way of populating an ADO dataset with a set of tables (and their data) from SQL Server and then all their relations based on the Foreign Key constraints defined on the SQL server database.

All examples I have seen online when googling show the relations being coded one by one in C# but I want them to be taken automatically from the relations that already exist on the tables in SQL server as FK constraints.

I am using c# under .NET Framework 4

I want to do something like......

1. Declare dataset.
2. List tables I am interested in and add these to the dataset with all of their data.
3. Add all relations based on FK Constraints in SQL Server DB.
 
create a strongly typed dataset to reflect the information you need.

I don't see much value in duplicating the schema in memory though. This only applies to simple forms-over-data UIs. anything beyond that and you are working with subsets of data in a context specific way. the context may not align 1:1 with the database schema.

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top