DataHelper.BuildStoredProcedureUpdateCommand

This method takes an empty command object as well as a data row, and builds
an SQL compliant update command, depending on the row state and update mode.
The command assumes that a certain Stored Procedure is available to perform
the desired update.

public static IDbCommand BuildStoredProcedureUpdateCommand( DataRow changedRow,
	KeyType primaryKeyType,
	string primaryKeyField,
	IDataService dataService,
	DataRowUpdateMode updateMode,
	string storedProcedurePrefix );

Return Value

Fully configured command object that is ready to be executed.

Parameters

changedRow
Updated data row

primaryKeyType
Primary key type (guid, integer,...)

primaryKeyField
Name of the primary key field

dataService
Instance of a concrete data service

updateMode
Should all fields be sent to the server, or only the changed ones?

storedProcedurePrefix
Prefix used for the stored procedure


Remarks

Stored Procedure update commands rely on a stored procedure of a certain name to be present. The name of the stored procedure follows the following pattern:

[Prefix]upd[TableName]

in a scenario where the default prefix is used, and the table name is Customer, the following Stored Procedure would be required:

milos_updCustomer

e SP needs to accept one parameter for each field (named the same as the fields - the cName field requires a corresponding @cName parameter) as well as an additional
rameter called @__cChangedFields, which contains a comma-separated list of all changed fields (with a trailing comma, and no spaces).
e Stored Procedure also needs to know (without any outside parameters) what the name of the primary key field is that is used to identify the updated row. This value is simply passed to this SP as one of the parameters.

See also:

Class DataHelper


  Last Updated: 5/23/2007 | © , 2007