DbCommandBuilder.GetInsertCommand Método
Definição
Sobrecargas
| GetInsertCommand() |
Obtém o objeto DbCommand gerado automaticamente necessário para realizar inserções na fonte de dados.Gets the automatically generated DbCommand object required to perform insertions at the data source. |
| GetInsertCommand(Boolean) |
Obtém o objeto DbCommand gerado automaticamente necessário para realizar inserções na fonte de dados, opcionalmente usando colunas para nomes de parâmetros.Gets the automatically generated DbCommand object required to perform insertions at the data source, optionally using columns for parameter names. |
Comentários
Um aplicativo pode usar o GetInsertCommand método para fins informativos ou de solução de problemas, pois retorna o texto do DbCommand objeto a ser executado.An application can use the GetInsertCommand method for informational or troubleshooting purposes because it returns the text of the DbCommand object to be executed.
Você também pode usar GetInsertCommand como a base de um comando modificado.You can also use GetInsertCommand as the basis of a modified command. Por exemplo, você pode chamar GetInsertCommand e modificar o texto do comando e, em seguida, defini-lo explicitamente no DbDataAdapter .For example, you might call GetInsertCommand and modify command text, and then explicitly set that on the DbDataAdapter.
Depois que a instrução SQL é gerada pela primeira vez, o aplicativo deve chamar explicitamente RefreshSchema se ele altera a instrução de qualquer forma.After the SQL statement is first generated, the application must explicitly call RefreshSchema if it changes the statement in any way. Caso contrário, o GetInsertCommand ainda estará usando informações da instrução anterior, que podem não estar corretas.Otherwise, the GetInsertCommand will still be using information from the previous statement, which might not be correct. As instruções SQL são geradas pela primeira vez quando o aplicativo chama Update ou GetInsertCommand .The SQL statements are first generated either when the application calls Update or GetInsertCommand.
O comportamento padrão, ao gerar nomes de parâmetro, é usar @p1 , @p2 e assim por diante para os vários parâmetros.The default behavior, when generating parameter names, is to use @p1, @p2, and so on for the various parameters. Se a versão sobrecarregada do GetInsertCommand permitir que você especifique esse comportamento, você poderá fazer com que o DbCommandBuilder gere parâmetros com base nos nomes de coluna.If the overloaded version of GetInsertCommand allows you to specify this behavior, you can cause the DbCommandBuilder to generate parameters based on the column names instead.
GetInsertCommand()
public:
System::Data::Common::DbCommand ^ GetInsertCommand();
public System.Data.Common.DbCommand GetInsertCommand ();
member this.GetInsertCommand : unit -> System.Data.Common.DbCommand
Public Function GetInsertCommand () As DbCommand
Retornos
O objeto DbCommand gerado automaticamente necessário para executar inserções.The automatically generated DbCommand object required to perform insertions.
Comentários
Um aplicativo pode usar o GetInsertCommand método para fins informativos ou de solução de problemas, pois retorna o texto do DbCommand objeto a ser executado.An application can use the GetInsertCommand method for informational or troubleshooting purposes because it returns the text of the DbCommand object to be executed.
Você também pode usar GetInsertCommand como a base de um comando modificado.You can also use GetInsertCommand as the basis of a modified command. Por exemplo, você pode chamar GetInsertCommand e modificar o texto do comando e, em seguida, defini-lo explicitamente no DbDataAdapter .For example, you might call GetInsertCommand and modify the command text, and then explicitly set that on the DbDataAdapter.
Depois que a instrução SQL é gerada pela primeira vez, o aplicativo deve chamar explicitamente RefreshSchema se ele altera a instrução de qualquer forma.After the SQL statement is first generated, the application must explicitly call RefreshSchema if it changes the statement in any way. Caso contrário, o GetInsertCommand ainda estará usando informações da instrução anterior, que podem não estar corretas.Otherwise, the GetInsertCommand will still be using information from the previous statement, which might not be correct. As instruções SQL são geradas pela primeira vez quando o aplicativo chama Update ou GetInsertCommand .The SQL statements are first generated either when the application calls Update or GetInsertCommand.
Aplica-se a
GetInsertCommand(Boolean)
Obtém o objeto DbCommand gerado automaticamente necessário para realizar inserções na fonte de dados, opcionalmente usando colunas para nomes de parâmetros.Gets the automatically generated DbCommand object required to perform insertions at the data source, optionally using columns for parameter names.
public:
System::Data::Common::DbCommand ^ GetInsertCommand(bool useColumnsForParameterNames);
public System.Data.Common.DbCommand GetInsertCommand (bool useColumnsForParameterNames);
member this.GetInsertCommand : bool -> System.Data.Common.DbCommand
Public Function GetInsertCommand (useColumnsForParameterNames As Boolean) As DbCommand
Parâmetros
- useColumnsForParameterNames
- Boolean
Se true, gerar nomes de parâmetro correspondentes a nomes de coluna, se possível.If true, generate parameter names matching column names, if possible. Se false, gerar @p1, @p2 e assim por diante.If false, generate @p1, @p2, and so on.
Retornos
O objeto DbCommand gerado automaticamente necessário para executar inserções.The automatically generated DbCommand object required to perform insertions.
Comentários
Um aplicativo pode usar o GetInsertCommand método para fins informativos ou de solução de problemas, pois retorna o texto do DbCommand objeto a ser executado.An application can use the GetInsertCommand method for informational or troubleshooting purposes because it returns the text of the DbCommand object to be executed.
Você também pode usar GetInsertCommand como a base de um comando modificado.You can also use GetInsertCommand as the basis of a modified command. Por exemplo, você pode chamar GetInsertCommand e modificar o texto do comando e, em seguida, defini-lo explicitamente no DbDataAdapter .For example, you might call GetInsertCommand and modify the command text, and then explicitly set that on the DbDataAdapter.
Depois que a instrução SQL é gerada pela primeira vez, o aplicativo deve chamar explicitamente RefreshSchema se ele altera a instrução de qualquer forma.After the SQL statement is first generated, the application must explicitly call RefreshSchema if it changes the statement in any way. Caso contrário, o GetInsertCommand ainda estará usando informações da instrução anterior, que podem não estar corretas.Otherwise, the GetInsertCommand will still be using information from the previous statement, which might not be correct. As instruções SQL são geradas pela primeira vez quando o aplicativo chama Update ou GetInsertCommand .The SQL statements are first generated either when the application calls Update or GetInsertCommand.
O comportamento padrão, ao gerar nomes de parâmetro, é usar @p1 , @p2 e assim por diante para os vários parâmetros.The default behavior, when generating parameter names, is to use @p1, @p2, and so on for the various parameters. A passagem do true useColumnsForParameterNames parâmetro permite forçar o DbCommandBuilder a gerar parâmetros com base nos nomes de coluna.Passing true for the useColumnsForParameterNames parameter allows you to force the DbCommandBuilder to generate parameters based on the column names instead. A geração dos parâmetros com base em nomes de coluna terá sucesso somente se as seguintes condições forem atendidas:Generation of the parameters based on column names succeeds only if the following conditions are met:
O ParameterNameMaxLength foi especificado e seu comprimento é igual ou maior que o nome de parâmetro gerado.The ParameterNameMaxLength has been specified and its length is equal to or greater than the generated parameter name.
O nome de parâmetro gerado atende aos critérios especificados na ParameterNamePattern expressão regular.The generated parameter name meets the criteria specified in the ParameterNamePattern regular expression.
Um ParameterMarkerFormat é especificado.A ParameterMarkerFormat is specified.