O'Reilly logo

A Programmer's Guide to .NET by Alexei Fedorov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required