12.7. Tables, rows, and columns
We already know that the DataSet contains a collection of tables. To access the tables in the DataSet we use the following syntax:
DS.Tables.Item("Employees")
or
DS.Tables.Item("Customers")
For example, to find the figure returned for the query about how many rows a table has, we can use the following code:
Cust_DA = New SqlDataAdapter("SELECT * FROM Customers", _ "server=localhost;database=Northwind;uid=sa;pwd=;") Cust_DA.Fill(DS, "Customers") Cust = DS.Tables.Item("Customers") Console.WriteLine(Cust.TableName & " contains " & _ Cust.Rows.Count & " record(s)")
Each item in the Tables collection is of a DataTable type. In the previous example, we used the Rows collection of the DataTable to find out how ...
Get A Programmer's Guide to .NET now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.