Uređivanje

Dijeli putem


DbDataSource.CreateCommand(String) Method

Definition

Returns a DbCommand that's ready for execution against the DbDataSource.

public System.Data.Common.DbCommand CreateCommand (string? commandText = default);
member this.CreateCommand : string -> System.Data.Common.DbCommand
Public Function CreateCommand (Optional commandText As String = Nothing) As DbCommand

Parameters

commandText
String

The text command with which to initialize the DbCommand that this method returns.

Returns

A DbCommand that's ready for execution against the DbDataSource.

Remarks

Commands returned from this method are already configured to execute against their originating DbDataSource; their Connection does not need to be set, and doing so will throw an exception.

Since these commands have no explicitly-managed connection, it is not possible to use them with transactions, and trying to set Transaction will throw an exception. To use a transaction, get a connection from OpenConnection and create a command against it.

Applies to