OleDbCommandBuilder.GetInsertCommand 方法

定义

获取在数据源中执行插入操作所需的自动生成的 OleDbCommand 对象。Gets the automatically generated OleDbCommand object required to perform insertions at the data source.

重载

GetInsertCommand()

获取在数据源中执行插入操作所需的自动生成的 OleDbCommand 对象。Gets the automatically generated OleDbCommand object required to perform insertions at the data source.

GetInsertCommand(Boolean)

获取在数据源中执行插入操作所需的自动生成的 OleDbCommand 对象。Gets the automatically generated OleDbCommand object required to perform insertions at the data source.

注解

应用程序可以使用 GetInsertCommand 方法进行信息性或故障排除,因为它返回 OleDbCommand 要执行的对象的文本。An application can use the GetInsertCommand method for informational or troubleshooting purposes because it returns the text of the OleDbCommand object to be executed.

您还可以将 GetInsertCommand 用作修改后的命令的基础。You can also use GetInsertCommand as the basis of a modified command. 例如,你可以调用 GetInsertCommand 并修改 CommandTimeout 值,然后在上显式设置该值 OleDbDataAdapterFor example, you might call GetInsertCommand and modify the CommandTimeout value, and then explicitly set that on the OleDbDataAdapter.

首次生成 SQL 语句后,如果应用程序 RefreshSchema 以任何方式更改语句,则必须显式调用。After the SQL statement is first generated, the application must explicitly call RefreshSchema if it changes the statement in any way. 否则, GetInsertCommand 仍将使用前一语句中的信息,这可能是不正确的。Otherwise, the GetInsertCommand will be still be using information from the previous statement, which might not be correct. 当应用程序调用或时,将首先生成 SQL UpdateCommand 语句 GetInsertCommandThe SQL statements are first generated when the application calls either UpdateCommand or GetInsertCommand.

GetInsertCommand()

获取在数据源中执行插入操作所需的自动生成的 OleDbCommand 对象。Gets the automatically generated OleDbCommand object required to perform insertions at the data source.

public:
 System::Data::OleDb::OleDbCommand ^ GetInsertCommand();
public System.Data.OleDb.OleDbCommand GetInsertCommand ();
override this.GetInsertCommand : unit -> System.Data.OleDb.OleDbCommand
member this.GetInsertCommand : unit -> System.Data.OleDb.OleDbCommand
Public Function GetInsertCommand () As OleDbCommand

返回

OleDbCommand

自动生成的、执行插入操作所需的 OleDbCommand 对象。The automatically generated OleDbCommand object required to perform insertions.

注解

应用程序可以使用 GetInsertCommand 方法进行信息性或故障排除,因为它返回 OleDbCommand 要执行的对象的文本。An application can use the GetInsertCommand method for informational or troubleshooting purposes because it returns the text of the OleDbCommand object to be executed.

您还可以将 GetInsertCommand 用作修改后的命令的基础。You can also use GetInsertCommand as the basis of a modified command. 例如,你可以调用 GetInsertCommand 并修改 CommandTimeout 值,然后在上显式设置该值 OleDbDataAdapterFor example, you might call GetInsertCommand and modify the CommandTimeout value, and then explicitly set that on the OleDbDataAdapter.

首次生成 SQL 语句后,如果应用程序 RefreshSchema 以任何方式更改语句,则必须显式调用。After the SQL statement is first generated, the application must explicitly call RefreshSchema if it changes the statement in any way. 否则, GetInsertCommand 仍将使用前一语句中的信息,这可能是不正确的。Otherwise, the GetInsertCommand will be still be using information from the previous statement, which might not be correct. 当应用程序调用或时,将首先生成 SQL UpdateCommand 语句 GetInsertCommandThe SQL statements are first generated when the application calls either UpdateCommand or GetInsertCommand.

适用于

GetInsertCommand(Boolean)

获取在数据源中执行插入操作所需的自动生成的 OleDbCommand 对象。Gets the automatically generated OleDbCommand object required to perform insertions at the data source.

public:
 System::Data::OleDb::OleDbCommand ^ GetInsertCommand(bool useColumnsForParameterNames);
public System.Data.OleDb.OleDbCommand GetInsertCommand (bool useColumnsForParameterNames);
override this.GetInsertCommand : bool -> System.Data.OleDb.OleDbCommand
Public Function GetInsertCommand (useColumnsForParameterNames As Boolean) As OleDbCommand

参数

useColumnsForParameterNames
Boolean

如果为 true,则如有可能,将生成与列名相匹配的参数名称。If true, generate parameter names matching column names, if it is possible. 如果为 false,则生成 @p1@p2,以此类推。If false, generate @p1, @p2, and so on.

返回

OleDbCommand

自动生成的、执行插入操作所需的 OleDbCommand 对象。The automatically generated OleDbCommand object required to perform insertions.

注解

应用程序可以使用 GetInsertCommand 方法进行信息性或故障排除,因为它返回 OleDbCommand 要执行的对象的文本。An application can use the GetInsertCommand method for informational or troubleshooting purposes because it returns the text of the OleDbCommand object to be executed.

您还可以将 GetInsertCommand 用作修改后的命令的基础。You can also use GetInsertCommand as the basis of a modified command. 例如,你可以调用 GetInsertCommand 并修改 CommandTimeout 值,然后在上显式设置该值 OleDbDataAdapterFor example, you might call GetInsertCommand and modify the CommandTimeout value, and then explicitly set that on the OleDbDataAdapter.

首次生成 SQL 语句后,如果应用程序 RefreshSchema 以任何方式更改语句,则必须显式调用。After the SQL statement is first generated, the application must explicitly call RefreshSchema if it changes the statement in any way. 否则, GetInsertCommand 仍将使用前一语句中的信息,这可能是不正确的。Otherwise, the GetInsertCommand will be still be using information from the previous statement, which might not be correct. 当应用程序调用或时,将首先生成 SQL UpdateCommand 语句 GetInsertCommandThe SQL statements are first generated when the application calls either UpdateCommand or GetInsertCommand.

生成参数名称时,默认行为是对 @p1 各种参数使用、 @p2 等。The default behavior, when generating parameter names, is to use @p1, @p2, and so on for the various parameters. 通过 trueuseColumnsForParameterNames 参数传递,可以强制根据 OleDbCommandBuilder 列名生成参数。Passing true for the useColumnsForParameterNames parameter lets you force the OleDbCommandBuilder to generate parameters based on the column names instead. 仅当满足以下条件时,此操作才会成功:This succeeds only if the following conditions are met:

适用于