O'Reilly logo

ADO.NET in a Nutshell by Bill Hamilton, Matthew MacDonald

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

Name

Fill

Synopsis


Int32 rowCount = DataAdapter.Fill(DataSet ds);

Int32 rowCount = DataAdapter.Fill(DataTable dt);

Int32 rowCount = DataAdapter.Fill(DataSet ds, String tableName);

Int32 rowCount = DataAdapter.Fill(DataSet ds, Int32 startRecord,

    Int32 maxRecords, String tableName);

Adds new rows or refreshes rows with changed data from the data source to the DataSet.

Parameters

rowCount

Returns the number of rows successfully created or refreshed from the data source.

ds

The DataSet to fill with records, and optionally, schema information.

dt

The DataTable to fill with records, and optionally, schema information.

tableName

The name of the DataTable in the DataSet to fill with the returned records.

startRecord

The zero-based record number, from the result set returned by the SQL statement, to start adding.

maxRecords

The number of records, from the result set returned by the SQL statement, to add.

Example

The following example demonstrates how to fill both a table within a DataSet object and a DataTable object using the Fill( ) method:

// connection string and select statement String connString = "Data Source=(local);Integrated security=SSPI;" + "Initial Catalog=Northwind;"; String selectSql = "SELECT * FROM Orders"; // create the data adapter SqlDataAdapter da = new SqlDataAdapter(selectSql, connString); // create a new DataSet to receive the Orders data DataSet ds = new DataSet(); // read all of the Orders data into a table named Orders in the DataSet da.Fill(ds, "Orders"); // create ...

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