There are two patterns for populating data:
Method 1 : Fill a DataTable – with this approach a method is created that takes in a DataTable as a parameter and populates it based on the results of the query. The ADO.NET DataAdapter class, for example, implements this pattern with its Fill() method.
Method 2 : Return a DataTable – with this approach the method creates and fills the DataTable for you and returns it as the methods return value.
There are two patterns commonly used for inserting, updating, and deleting data.
Method 1 : Database direct pattern, involves creating methods that, when invoked, issue an INSERT, UPDATE, or DELETE command to the database that operates on a single database record. Such methods are typically passed in a series of scalar values (integers, strings, Booleans, DateTimes, and so on) that correspond to the values to insert, update, or delete.
Method 2: Batch update pattern, is to update an entire DataSet, DataTable, or collection of DataRows in one method call. With this pattern a developer deletes, inserts, and modifies the DataRows in a DataTable and then passes those DataRows or DataTable into an update method. This method then enumerates the DataRows passed in, determines whether or not they've been modified, added, or deleted (via the DataRow's RowState property value), and issues the appropriate database request for each record.
The TableAdapter uses the batch update pattern by default, but also supports the DB direct pattern.
Both data modification patterns use the TableAdapter's InsertCommand, UpdateCommand, and DeleteCommand properties to issue their INSERT, UPDATE, and DELETE commands to the database.
source : http://msdn.microsoft.com/en-us/library/ms233701(VS.80).aspx
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment