Dataset Object
In c sharp How to Set or return the name of the current index for a dataset object. Can someone post and example or lead me to the right place?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
David SmithPosted Oct 14, 2014, 12:41 PM
VulpesPosted Oct 14, 2014, 12:01 PM
Although you can't index the DataSet itself, you can index its Tables and Relations properties. This can be done either numerically (starting from 0) or by name.
So, for example, if you wanted to get a reference to the first (or only) DataTable in some DataSet (ds, say), you could do it either like this:
DataTable dt = ds.Tables[0];
or like this:
DataTable dt = ds.Tables["MyTableName"];
All DataTables have a TableName property which returns their name and a DataSet property which returns a reference to the DataSet to which they belong.