yonan2236
yonan2236

Reputation: 13659

How to access the dataTables in a DataSet

I have created this DataSet and add a DataTable on it.

enter image description here

My problem is I don't know how to access this DataTable (Addresses) in my program.

enter image description here

Please advise. Thanks.

Upvotes: 2

Views: 201

Answers (1)

Marc Gravell
Marc Gravell

Reputation: 1063864

DataSet1 is the type; you need an instance that you load with data via an adapter. That should then be easily available:

DataSet1 ds = new DataSet1();
// todo: use an adapter to load the desired data
var addresses = ds.Addresses;

Or

var addresses = ds["Addresses"];

That said; dataset/DataTable is definitely not how I would do data access. You might want to look instead at tools like LINQ-to-SQL or Entity Framework.

Upvotes: 8

Related Questions