Class MySqlCommandBuilder
Automatically generates single-table commands used to reconcile changes made to a System.
Inheritance
Implements
Namespace: MySql.Data.MySqlClient
Assembly: MySql.Data.dll
Version: 9.3.0
Syntax
public sealed class MySqlCommandBuilder : DbCommandBuilder, IComponent, IDisposable
Remarks
The My
The My
To generate INSERT, UPDATE, or DELETE statements, the My
The System.
The My
If you call System.
Examples
The following example uses the My
public static DataSet SelectRows(string myConnection, string mySelectQuery, string myTableName)
{
MySqlConnection myConn = new MySqlConnection(myConnection);
MySqlDataAdapter myDataAdapter = new MySqlDataAdapter();
myDataAdapter.SelectCommand = new MySqlCommand(mySelectQuery, myConn);
MySqlCommandBuilder cb = new MySqlCommandBuilder(myDataAdapter);
myConn.Open();
DataSet ds = new DataSet();
myDataAdapter.Fill(ds, myTableName);
///code to modify data in DataSet here
///Without the MySqlCommandBuilder this line would fail
myDataAdapter.Update(ds, myTableName);
myConn.Close();
return ds;
}
Constructors
MySqlCommandBuilder()
Initializes a new instance of the My
Declaration
public MySqlCommandBuilder()
MySqlCommandBuilder(MySqlDataAdapter)
Initializes a new instance of the My
Declaration
public MySqlCommandBuilder(MySqlDataAdapter adapter)
Parameters
Type | Name | Description |
---|---|---|
My |
adapter | The My |
Remarks
The My
When you create a new instance My
Properties
DataAdapter
Gets or sets a My
Declaration
public MySqlDataAdapter DataAdapter { get; set; }
Property Value
Type | Description |
---|---|
My |
A My |
Remarks
The My
When you create a new instance My
Methods
ApplyParameterInfo(DbParameter, DataRow, StatementType, Boolean)
Allows the provider implementation of the System.
Declaration
protected override void ApplyParameterInfo(DbParameter parameter, DataRow row, StatementType statementType, bool whereClause)
Parameters
Type | Name | Description |
---|---|---|
System. |
parameter | A System. |
System. |
row | The System. |
System. |
statementType | The type of command being generated; INSERT, UPDATE or DELETE. |
System. |
whereClause | true if the parameter is part of the update or delete WHERE clause, false if it is part of the insert or update values. |
Overrides
DeriveParameters(MySqlCommand)
Retrieves parameter information from the stored procedure specified in the My
Declaration
public static void DeriveParameters(MySqlCommand command)
Parameters
Type | Name | Description |
---|---|---|
My |
command | The My |
Exceptions
Type | Condition |
---|---|
System. |
The command text is not a valid stored procedure name. |
GetDeleteCommand()
Gets the delete command.
Declaration
public MySqlCommand GetDeleteCommand()
Returns
Type | Description |
---|---|
My |
The My |
GetInsertCommand()
Gets the insert command.
Declaration
public MySqlCommand GetInsertCommand()
Returns
Type | Description |
---|---|
My |
The My |
GetParameterName(Int32)
Returns the name of the specified parameter in the format of @p#. Use when building a custom command builder.
Declaration
protected override string GetParameterName(int parameterOrdinal)
Parameters
Type | Name | Description |
---|---|---|
System. |
parameterOrdinal | The number to be included as part of the parameter's name. |
Returns
Type | Description |
---|---|
System. |
The name of the parameter with the specified number appended as part of the parameter name. |
Overrides
GetParameterName(String)
Returns the full parameter name, given the partial parameter name.
Declaration
protected override string GetParameterName(string parameterName)
Parameters
Type | Name | Description |
---|---|---|
System. |
parameterName | The partial name of the parameter. |
Returns
Type | Description |
---|---|
System. |
The full parameter name corresponding to the partial parameter name requested. |
Overrides
GetParameterPlaceholder(Int32)
Returns the placeholder for the parameter in the associated SQL statement.
Declaration
protected override string GetParameterPlaceholder(int parameterOrdinal)
Parameters
Type | Name | Description |
---|---|---|
System. |
parameterOrdinal | The number to be included as part of the parameter's name. |
Returns
Type | Description |
---|---|
System. |
The name of the parameter with the specified number appended. |
Overrides
GetSchemaTable(DbCommand)
Returns the schema table for the My
Declaration
protected override DataTable GetSchemaTable(DbCommand sourceCommand)
Parameters
Type | Name | Description |
---|---|---|
System. |
sourceCommand | The System. |
Returns
Type | Description |
---|---|
System. |
A System. |
Overrides
GetUpdateCommand()
Gets the update command.
Declaration
public MySqlCommand GetUpdateCommand()
Returns
Type | Description |
---|---|
My |
The My |
QuoteIdentifier(String)
Given an unquoted identifier in the correct catalog case, returns the correct quoted form of that identifier, including properly escaping any embedded quotes in the identifier.
Declaration
public override string QuoteIdentifier(string unquotedIdentifier)
Parameters
Type | Name | Description |
---|---|---|
System. |
unquotedIdentifier | The original unquoted identifier. |
Returns
Type | Description |
---|---|
System. |
The quoted version of the identifier. Embedded quotes within the identifier are properly escaped. |
Overrides
Exceptions
Type | Condition |
---|---|
System. |
If the unquotedIdentifier is null. |
SetRowUpdatingHandler(DbDataAdapter)
Registers the My
Declaration
protected override void SetRowUpdatingHandler(DbDataAdapter adapter)
Parameters
Type | Name | Description |
---|---|---|
System. |
adapter |
Overrides
UnquoteIdentifier(String)
Given a quoted identifier, returns the correct unquoted form of that identifier, including properly un-escaping any embedded quotes in the identifier.
Declaration
public override string UnquoteIdentifier(string quotedIdentifier)
Parameters
Type | Name | Description |
---|---|---|
System. |
quotedIdentifier | The identifier that will have its embedded quotes removed. |
Returns
Type | Description |
---|---|
System. |
The unquoted identifier, with embedded quotes properly un-escaped. |
Overrides
Exceptions
Type | Condition |
---|---|
System. |
If the quotedIdentifier is null. |