| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
SqlCommandBuilder ClassSystem.Data.SqlClient Namespace Provides a means of automatically generating single-table commands used to reconcile changes made to a DataSet with the associated SQL Server™ database.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Visibility | Name | Value Type | Accessibility |
|---|---|---|---|
| public | CatalogLocation | CatalogLocation | [ Get , Set ] |
| public | CatalogSeparator | String | [ Get , Set ] |
| public | DataAdapter | SqlDataAdapter | [ Get , Set ] |
| public | QuotePrefix | String | [ Get , Set ] |
| public | QuoteSuffix | String | [ Get , Set ] |
| public | SchemaSeparator | String | [ Get , Set ] |
| Visibility | Name | Parameters | Return Type |
|---|---|---|---|
| protected | ApplyParameterInfo | ( DbParameter parameter , DataRow datarow , StatementType statementType , Boolean whereClause ) | Void |
| public static | DeriveParameters | ( SqlCommand command ) | Void |
| public | GetDeleteCommand | ( ) | SqlCommand |
| public | GetDeleteCommand | ( Boolean useColumnsForParameterNames ) | SqlCommand |
| public | GetInsertCommand | ( Boolean useColumnsForParameterNames ) | SqlCommand |
| public | GetInsertCommand | ( ) | SqlCommand |
| protected | GetParameterName | ( String parameterName ) | String |
| protected | GetParameterName | ( Int32 parameterOrdinal ) | String |
| protected | GetParameterPlaceholder | ( Int32 parameterOrdinal ) | String |
| protected | GetSchemaTable | ( DbCommand srcCommand ) | DataTable |
| public | GetUpdateCommand | ( Boolean useColumnsForParameterNames ) | SqlCommand |
| public | GetUpdateCommand | ( ) | SqlCommand |
| protected | InitializeCommand | ( DbCommand command ) | DbCommand |
| public | QuoteIdentifier | ( String unquotedIdentifier ) | String |
| protected | SetRowUpdatingHandler | ( DbDataAdapter adapter ) | Void |
| public | UnquoteIdentifier | ( String quotedIdentifier ) | String |
The SqlDataAdapter does not automatically generate the Transact-SQL statements required to reconcile changes made to a DataSet with the associated instance of SQL Server. However, you can create an SqlCommandBuilder object to automatically generate Transact-SQL statements for single-table updates if you set the SelectCommand property of the SqlDataAdapter. Then, any additional Transact-SQL statements that you do not set are generated by the SqlCommandBuilder.
The SqlCommandBuilder registers itself as a listener for RowUpdating events whenever you set the DataAdapter property. You can only associate one SqlDataAdapter or SqlCommandBuilder object with each other at one time.
To generate INSERT, UPDATE, or DELETE statements, the SqlCommandBuilder uses the SelectCommand property to retrieve a required set of metadata automatically. If you change the SelectCommand after the metadata has is retrieved ( for example, after the first update ), you should call the RefreshSchema method to update the metadata.
The SqlCommandBuilder also uses the Connection, CommandTimeout, and Transaction properties referenced by the SelectCommand. The user should call RefreshSchema if any of these properties are modified, or if the SelectCommand itself is replaced. Otherwise the InsertCommand, UpdateCommand, and DeleteCommand properties retain their previous values.
If you call Dispose, the SqlCommandBuilder is disassociated from the SqlDataAdapter, and the generated commands are no longer used.
The following examples demonstrate using the SqlCommandBuilder to dynamically generate the INSERT, UPDATE, and DELETE statements of a given SqlDataAdapter.
|
|
|
SqlCommand SqlDataAdapter Updating Data at the DataSet Level
Check out related books at Amazon
© 2000-2008 Rey Nuñez All rights reserved.
If you have any question, comment or suggestion
about this site, please send us a note
You can help support aspxtreme