OdbcCommand Sınıf
Tanım
Bir veri kaynağında yürütülecek bir SQL ifadesini veya saklı yordamı temsil eder.Represents an SQL statement or stored procedure to execute against a data source. Bu sınıf devralınamaz.This class cannot be inherited.
public ref class OdbcCommand sealed : System::Data::Common::DbCommand, ICloneable
public ref class OdbcCommand sealed : System::ComponentModel::Component, ICloneable, IDisposable, System::Data::IDbCommand
public sealed class OdbcCommand : System.Data.Common.DbCommand, ICloneable
public sealed class OdbcCommand : System.ComponentModel.Component, ICloneable, IDisposable, System.Data.IDbCommand
type OdbcCommand = class
inherit DbCommand
interface ICloneable
type OdbcCommand = class
inherit Component
interface ICloneable
interface IDbCommand
interface IDisposable
Public NotInheritable Class OdbcCommand
Inherits DbCommand
Implements ICloneable
Public NotInheritable Class OdbcCommand
Inherits Component
Implements ICloneable, IDbCommand, IDisposable
- Devralma
- Devralma
- Devralma
- Uygulamalar
Örnekler
Aşağıdaki örnek kullanılmıştır ExecuteNonQuery .The following example uses ExecuteNonQuery.
public void InsertRow(string connectionString, string insertSQL)
{
using (OdbcConnection connection =
new OdbcConnection(connectionString))
{
// The insertSQL string contains a SQL statement that
// inserts a new row in the source table.
OdbcCommand command = new OdbcCommand(insertSQL, connection);
// Open the connection and execute the insert command.
try
{
connection.Open();
command.ExecuteNonQuery();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
// The connection is automatically closed when the
// code exits the using block.
}
Public Sub InsertRow(ByVal connectionString As String, _
ByVal insertSQL As String)
Using connection As New OdbcConnection(connectionString)
' The insertSQL string contains a SQL statement that
' inserts a new row in the source table.
Dim command As New OdbcCommand(insertSQL, connection)
' Open the connection and execute the insert command.
Try
connection.Open()
command.ExecuteNonQuery()
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
' The connection is automatically closed when the
' code exits the Using block.
End Using
End Sub
Açıklamalar
OdbcCommandSınıfı, bir veri kaynağına karşı komutları yürütmek için aşağıdaki yöntemleri sağlar:The OdbcCommand class provides the following methods for executing commands against a data source:
ÖğeItem | AçıklamaDescription |
---|---|
ExecuteReader | Satırları döndüren komutları yürütür.Executes commands that return rows. |
ExecuteNonQuery | SQL INSERT, DELETE, UPDATE ve SET deyimleri gibi komutları yürütür.Executes commands such as SQL INSERT, DELETE, UPDATE, and SET statements. |
ExecuteScalar | Bir veritabanından bir toplama değeri gibi tek bir değer alır.Retrieves a single value, for example, an aggregate value, from a database. |
CommandTextÖzelliği sıfırlayabilir ve nesneyi yeniden kullanabilirsiniz OdbcCommand .You can reset the CommandText property and reuse the OdbcCommand object. Bununla birlikte, OdbcDataReader Yeni veya önceki bir komutu yürütebilmeniz için önce ' i kapatmanız gerekir.However, you must close the OdbcDataReader before you can execute a new or previous command.
Komutun yürütülmesi OdbcException 20 veya daha fazla SQL Server önem derecesi düzeyi gibi önemli bir durum oluşmasına neden oluyorsa, OdbcConnection kapatılabilir.If execution of the command causes a fatal OdbcException such as a SQL Server severity level of 20 or more, OdbcConnection may close. Ancak, Kullanıcı bağlantıyı yeniden açabilir ve devam edebilir.However, the user can reopen the connection and continue.
Oluşturucular
OdbcCommand() |
OdbcCommand sınıfının yeni bir örneğini başlatır.Initializes a new instance of the OdbcCommand class. |
OdbcCommand(String) |
OdbcCommandSorgunun metniyle birlikte sınıfının yeni bir örneğini başlatır.Initializes a new instance of the OdbcCommand class with the text of the query. |
OdbcCommand(String, OdbcConnection) |
OdbcCommandSorgunun ve bir nesnenin metniyle birlikte sınıfının yeni bir örneğini başlatır OdbcConnection .Initializes a new instance of the OdbcCommand class with the text of the query and an OdbcConnection object. |
OdbcCommand(String, OdbcConnection, OdbcTransaction) |
OdbcCommandSorgunun metnini, bir nesnesini ve ' i içeren, sınıfının yeni bir örneğini başlatır OdbcConnection Transaction .Initializes a new instance of the OdbcCommand class with the text of the query, an OdbcConnection object, and the Transaction. |
Özellikler
CanRaiseEvents |
Bileşenin bir olay yapıp yapamayacağını gösteren bir değer alır.Gets a value indicating whether the component can raise an event. (Devralındığı yer: Component) |
CommandText |
Veri kaynağında yürütülecek SQL ifadesini veya saklı yordamı alır veya ayarlar.Gets or sets the SQL statement or stored procedure to execute against the data source. |
CommandTimeout |
Bir komutu yürütmeye ve hata oluşturmaya yönelik bir girişimi sonlandırmadan önce bekleme süresini (saniye cinsinden) alır veya ayarlar.Gets or sets the wait time (in seconds) before terminating an attempt to execute a command and generating an error. |
CommandType |
Özelliğin nasıl yorumlandığını gösteren bir değer alır veya ayarlar CommandText .Gets or sets a value that indicates how the CommandText property is interpreted. |
Connection |
OdbcConnectionBu örneği tarafından kullanılan öğesini alır veya ayarlar OdbcCommand .Gets or sets the OdbcConnection used by this instance of the OdbcCommand. |
Container |
Öğesini içeren öğesini alır IContainer Component .Gets the IContainer that contains the Component. (Devralındığı yer: Component) |
DbConnection |
Türetilmiş bir sınıfta geçersiz kılındığında, bu tarafından kullanılan ' ı alır veya ayarlar DbConnection DbCommand .When overridden in a derived class, gets or sets the DbConnection used by this DbCommand. (Devralındığı yer: DbCommand) |
DbParameterCollection |
Türetilmiş bir sınıfta geçersiz kılındığında, nesne koleksiyonunu alır DbParameter .When overridden in a derived class, gets the collection of DbParameter objects. (Devralındığı yer: DbCommand) |
DbTransaction |
Türetilmiş bir sınıfta geçersiz kılındığında, bu nesnenin içinde çalıştırıldığı ' ı alır veya ayarlar DbTransaction DbCommand .When overridden in a derived class, gets or sets the DbTransaction within which this DbCommand object executes. (Devralındığı yer: DbCommand) |
DesignMode |
Şu anda Tasarım modunda olup olmadığını gösteren bir değer alır Component .Gets a value that indicates whether the Component is currently in design mode. (Devralındığı yer: Component) |
DesignTimeVisible |
Komut nesnesinin özelleştirilmiş bir arabirim denetiminde görünür olup olmayacağını gösteren bir değer alır veya ayarlar.Gets or sets a value that indicates whether the command object should be visible in a customized interface control. |
Events |
Bu öğesine eklenen olay işleyicilerinin listesini alır Component .Gets the list of event handlers that are attached to this Component. (Devralındığı yer: Component) |
Parameters |
OdbcParameterCollection öğesini alır.Gets the OdbcParameterCollection. |
Site |
Öğesini alır veya ayarlar ISite Component .Gets or sets the ISite of the Component. (Devralındığı yer: Component) |
Transaction |
OdbcTransactionİçindeki yürütmelerinin alır veya ayarlar OdbcCommand .Gets or sets the OdbcTransaction within which the OdbcCommand executes. |
UpdatedRowSource |
Update yönteminin DataRow'a nasıl komut sonuçları uygulanacağını belirten bir değer alır veya ayarlar.Gets or sets a value that specifies how the Update method should apply command results to the DataRow. |
Yöntemler
Cancel() |
Yürütmesini iptal etmeyi dener OdbcCommand .Tries to cancel the execution of an OdbcCommand. |
CreateDbParameter() |
Türetilmiş bir sınıfta geçersiz kılınırsa, bir nesnenin yeni bir örneğini oluşturur DbParameter .When overridden in a derived class, creates a new instance of a DbParameter object. (Devralındığı yer: DbCommand) |
CreateObjRef(Type) |
Uzak bir nesneyle iletişim kurmak için kullanılan bir ara sunucu oluşturmak için gereken tüm bilgileri içeren bir nesne oluşturur.Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Devralındığı yer: MarshalByRefObject) |
CreateParameter() |
Bir nesnenin yeni bir örneğini oluşturur OdbcParameter .Creates a new instance of an OdbcParameter object. |
Dispose() |
Uygulama tarafından tanımlanan, yönetilmeyen kaynakları serbest bırakma, salma veya sıfırlama ile ilişkili görevleri gerçekleştirir.Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. (Devralındığı yer: DbCommand) |
Dispose() |
Component tarafından kullanılan tüm kaynakları serbest bırakır.Releases all resources used by the Component. (Devralındığı yer: Component) |
Dispose(Boolean) |
DbCommand tarafından kullanılan yönetilmeyen kaynakları serbest bırakır ve yönetilen kaynakları isteğe bağlı olarak serbest bırakır.Releases the unmanaged resources used by the DbCommand and optionally releases the managed resources. (Devralındığı yer: DbCommand) |
Dispose(Boolean) |
Component tarafından kullanılan yönetilmeyen kaynakları serbest bırakır ve yönetilen kaynakları isteğe bağlı olarak serbest bırakır.Releases the unmanaged resources used by the Component and optionally releases the managed resources. (Devralındığı yer: Component) |
DisposeAsync() |
Komut nesnesini zaman uyumsuz olarak atar.Asynchronously diposes the command object. (Devralındığı yer: DbCommand) |
Equals(Object) |
Belirtilen nesnenin geçerli nesneye eşit olup olmadığını belirler.Determines whether the specified object is equal to the current object. (Devralındığı yer: Object) |
ExecuteDbDataReader(CommandBehavior) |
Türetilmiş bir sınıfta geçersiz kılınırsa, bağlantı için komut metnini yürütür.When overridden in a derived class, executes the command text against the connection. (Devralındığı yer: DbCommand) |
ExecuteDbDataReaderAsync(CommandBehavior, CancellationToken) |
Sağlayıcılar, aşırı yüklemeler için varsayılan olmayan bir uygulama sağlamak üzere bu yöntemi uygulamalıdır ExecuteReader .Providers should implement this method to provide a non-default implementation for ExecuteReader overloads. Varsayılan uygulama, zaman uyumlu ExecuteReader() yöntemi çağırır ve tamamlanan bir görevi döndürür ve çağıran iş parçacığını engeller.The default implementation invokes the synchronous ExecuteReader() method and returns a completed task, blocking the calling thread. Zaten iptal edilmiş bir iptal belirteci geçirilirse varsayılan uygulama iptal edilen bir görev döndürür.The default implementation will return a cancelled task if passed an already cancelled cancellation token. ExecuteReader tarafından oluşturulan özel durumlar, döndürülen görev özel durumu özelliği aracılığıyla iletilecektir.Exceptions thrown by ExecuteReader will be communicated via the returned Task Exception property. Bu yöntem, işlemi erken iptal edilecek şekilde istemek için kullanılabilen bir iptal belirtecini kabul eder.This method accepts a cancellation token that can be used to request the operation to be cancelled early. Uygulamalar bu isteği yok sayabilir.Implementations may ignore this request. (Devralındığı yer: DbCommand) |
ExecuteNonQuery() |
, ' A karşı bir SQL ifadesini yürütür Connection ve etkilenen satır sayısını döndürür.Executes an SQL statement against the Connection and returns the number of rows affected. |
ExecuteNonQueryAsync() |
Bir ExecuteNonQuery() bağlantı nesnesine yönelik BIR SQL ifadesini yürüten zaman uyumsuz bir sürümü.An asynchronous version of ExecuteNonQuery(), which executes a SQL statement against a connection object. ExecuteNonQueryAsync(CancellationToken)CancellationToken. None ile çağırır.Invokes ExecuteNonQueryAsync(CancellationToken) with CancellationToken.None. (Devralındığı yer: DbCommand) |
ExecuteNonQueryAsync(CancellationToken) |
Bu, öğesinin zaman uyumsuz sürümüdür ExecuteNonQuery() .This is the asynchronous version of ExecuteNonQuery(). Sağlayıcılar uygun bir uygulamayla geçersiz kılmalıdır.Providers should override with an appropriate implementation. İptal belirteci isteğe bağlı olarak yoksayılabilir.The cancellation token may optionally be ignored. Varsayılan uygulama, zaman uyumlu ExecuteNonQuery() yöntemi çağırır ve tamamlanan bir görevi döndürür ve çağıran iş parçacığını engeller.The default implementation invokes the synchronous ExecuteNonQuery() method and returns a completed task, blocking the calling thread. Zaten iptal edilmiş bir iptal belirteci geçirilirse varsayılan uygulama iptal edilen bir görev döndürür.The default implementation will return a cancelled task if passed an already cancelled cancellation token. Tarafından oluşturulan özel durumlar ExecuteNonQuery() , döndürülen görev özel durumu özelliği aracılığıyla iletilecektir.Exceptions thrown by ExecuteNonQuery() will be communicated via the returned Task Exception property. Döndürülen görev tamamlanana kadar nesnenin diğer yöntemlerini ve özelliklerini çağırmayın |
ExecuteReader() |
' A gönderir CommandText Connection ve bir oluşturur OdbcDataReader .Sends the CommandText to the Connection and builds an OdbcDataReader. |
ExecuteReader(CommandBehavior) |
' A gönderir CommandText Connection ve OdbcDataReader değerlerinden birini kullanarak bir oluşturur |
ExecuteReaderAsync() |
ExecuteReader' I ' CommandText a karşı yürüten Connection ve döndüren zaman uyumsuz bir sürümü DbDataReader .An asynchronous version of ExecuteReader, which executes the CommandText against the Connection and returns a DbDataReader. ExecuteDbDataReaderAsync(CommandBehavior, CancellationToken)CancellationToken. None ile çağırır.Invokes ExecuteDbDataReaderAsync(CommandBehavior, CancellationToken) with CancellationToken.None. (Devralındığı yer: DbCommand) |
ExecuteReaderAsync(CancellationToken) |
ExecuteReader' I ' CommandText a karşı yürüten Connection ve döndüren zaman uyumsuz bir sürümü DbDataReader .An asynchronous version of ExecuteReader, which executes the CommandText against the Connection and returns a DbDataReader. Bu yöntem, işlemlerin iptal edilmesi gerektiğini belirten bir bildirim yayar.This method propagates a notification that operations should be canceled. Çağırır ExecuteDbDataReaderAsync(CommandBehavior, CancellationToken) .Invokes ExecuteDbDataReaderAsync(CommandBehavior, CancellationToken). (Devralındığı yer: DbCommand) |
ExecuteReaderAsync(CommandBehavior) |
ExecuteReader' I ' CommandText a karşı yürüten Connection ve döndüren zaman uyumsuz bir sürümü DbDataReader .An asynchronous version of ExecuteReader, which executes the CommandText against the Connection and returns a DbDataReader. Çağırır ExecuteDbDataReaderAsync(CommandBehavior, CancellationToken) .Invokes ExecuteDbDataReaderAsync(CommandBehavior, CancellationToken). (Devralındığı yer: DbCommand) |
ExecuteReaderAsync(CommandBehavior, CancellationToken) |
Çağırır ExecuteDbDataReaderAsync(CommandBehavior, CancellationToken) .Invokes ExecuteDbDataReaderAsync(CommandBehavior, CancellationToken). (Devralındığı yer: DbCommand) |
ExecuteScalar() |
Sorguyu yürütür ve sorgu tarafından döndürülen sonuç kümesindeki ilk satırın ilk sütununu döndürür.Executes the query, and returns the first column of the first row in the result set returned by the query. Ek sütunlar veya satırlar yok sayılır.Additional columns or rows are ignored. |
ExecuteScalarAsync() |
ExecuteScalar()Sorgusunu yürüten ve sorgu tarafından döndürülen sonuç kümesindeki ilk satırın ilk sütununu döndüren zaman uyumsuz bir sürümü.An asynchronous version of ExecuteScalar(), which executes the query and returns the first column of the first row in the result set returned by the query. Diğer tüm sütunlar ve satırlar yok sayılır.All other columns and rows are ignored. ExecuteScalarAsync(CancellationToken)CancellationToken. None ile çağırır.Invokes ExecuteScalarAsync(CancellationToken) with CancellationToken.None. (Devralındığı yer: DbCommand) |
ExecuteScalarAsync(CancellationToken) |
Bu, öğesinin zaman uyumsuz sürümüdür ExecuteScalar() .This is the asynchronous version of ExecuteScalar(). Sağlayıcılar uygun bir uygulamayla geçersiz kılmalıdır.Providers should override with an appropriate implementation. İptal belirteci isteğe bağlı olarak yoksayılabilir.The cancellation token may optionally be ignored. Varsayılan uygulama, zaman uyumlu ExecuteScalar() yöntemi çağırır ve tamamlanan bir görevi döndürür ve çağıran iş parçacığını engeller.The default implementation invokes the synchronous ExecuteScalar() method and returns a completed task, blocking the calling thread. Zaten iptal edilmiş bir iptal belirteci geçirilirse varsayılan uygulama iptal edilen bir görev döndürür.The default implementation will return a cancelled task if passed an already cancelled cancellation token. ExecuteReader metodunu tarafından oluşturulan özel durumlar, döndürülen görev özel durumu özelliği aracılığıyla iletilecektir.Exceptions thrown by ExecuteScalar will be communicated via the returned Task Exception property. Döndürülen görev tamamlanana kadar nesnenin diğer yöntemlerini ve özelliklerini çağırmayın |
GetHashCode() |
Varsayılan karma işlevi olarak işlev görür.Serves as the default hash function. (Devralındığı yer: Object) |
GetLifetimeService() |
Bu örnek için ömür ilkesini denetleyen geçerli ömür hizmeti nesnesini alır.Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Devralındığı yer: MarshalByRefObject) |
GetService(Type) |
Veya tarafından belirtilen bir hizmeti temsil eden bir nesne döndürür Component Container .Returns an object that represents a service provided by the Component or by its Container. (Devralındığı yer: Component) |
GetType() |
TypeGeçerli örneği alır.Gets the Type of the current instance. (Devralındığı yer: Object) |
InitializeLifetimeService() |
Bu örnek için ömür ilkesini denetlemek üzere bir ömür hizmeti nesnesi alır.Obtains a lifetime service object to control the lifetime policy for this instance. (Devralındığı yer: MarshalByRefObject) |
MemberwiseClone() |
Geçerli bir basit kopyasını oluşturur Object .Creates a shallow copy of the current Object. (Devralındığı yer: Object) |
MemberwiseClone(Boolean) |
Geçerli nesnenin basit bir kopyasını oluşturur MarshalByRefObject .Creates a shallow copy of the current MarshalByRefObject object. (Devralındığı yer: MarshalByRefObject) |
Prepare() |
Veri kaynağında komutun hazırlanmış veya derlenmiş bir sürümünü oluşturur.Creates a prepared or compiled version of the command at the data source. |
PrepareAsync(CancellationToken) |
Zaman uyumsuz olarak, veri kaynağında komutun hazırlanmış (veya derlenen) bir sürümünü oluşturur.Asynchronously creates a prepared (or compiled) version of the command on the data source. (Devralındığı yer: DbCommand) |
ResetCommandTimeout() |
CommandTimeoutÖzelliği varsayılan değere sıfırlar.Resets the CommandTimeout property to the default value. |
ToString() |
Geçerli nesneyi temsil eden dizeyi döndürür.Returns a string that represents the current object. (Devralındığı yer: Object) |
ToString() |
Varsa, String varsa adını içeren bir döndürür Component .Returns a String containing the name of the Component, if any. Bu yöntem geçersiz kılınmamalıdır.This method should not be overridden. (Devralındığı yer: Component) |
Ekinlikler
Disposed |
Bileşen yönteme bir çağrı tarafından bırakıldığında gerçekleşir Dispose() .Occurs when the component is disposed by a call to the Dispose() method. (Devralındığı yer: Component) |
Belirtik Arabirim Kullanımları
ICloneable.Clone() |
Bu üyenin açıklaması için bkz Clone() ..For a description of this member, see Clone(). |
IDbCommand.Connection |
IDbConnectionBu örneği tarafından kullanılan öğesini alır veya ayarlar IDbCommand .Gets or sets the IDbConnection used by this instance of the IDbCommand. (Devralındığı yer: DbCommand) |
IDbCommand.CreateParameter() | |
IDbCommand.CreateParameter() |
Bir nesnenin yeni bir örneğini oluşturur IDbDataParameter .Creates a new instance of an IDbDataParameter object. (Devralındığı yer: DbCommand) |
IDbCommand.ExecuteReader() |
Bu API, ürün altyapısını destekler ve doğrudan kodunuzdan kullanıma yönelik değildir. ' A CommandText karşı yürütülür Connection ve bir oluşturur IDataReader .Executes the CommandText against the Connection and builds an IDataReader. |
IDbCommand.ExecuteReader() |
' A CommandText karşı yürütülür Connection ve bir oluşturur IDataReader .Executes the CommandText against the Connection and builds an IDataReader. (Devralındığı yer: DbCommand) |
IDbCommand.ExecuteReader(CommandBehavior) |
Bu API, ürün altyapısını destekler ve doğrudan kodunuzdan kullanıma yönelik değildir. , CommandText ' A karşı yürütülür Connection ve IDataReader belirtilen davranışı kullanarak bir oluşturur.Executes the CommandText against the Connection, and builds an IDataReader using the specified behavior. |
IDbCommand.ExecuteReader(CommandBehavior) |
, CommandText ' A karşı yürütülür Connection ve IDataReader değerlerden birini kullanarak bir oluşturur CommandBehavior .Executes the CommandText against the Connection, and builds an IDataReader using one of the CommandBehavior values. (Devralındığı yer: DbCommand) |
IDbCommand.Parameters |
IDataParameterCollection öğesini alır.Gets the IDataParameterCollection. (Devralındığı yer: DbCommand) |
IDbCommand.Transaction |
DbTransactionBu nesnenin içinde çalıştırıldığı içindeki öğesini alır veya ayarlar DbCommand .Gets or sets the DbTransaction within which this DbCommand object executes. (Devralındığı yer: DbCommand) |