Aracılığıyla paylaş


OleDbDataAdapter Oluşturucular

Tanım

OleDbDataAdapter sınıfının yeni bir örneğini başlatır.

Aşırı Yüklemeler

OleDbDataAdapter()

OleDbDataAdapter sınıfının yeni bir örneğini başlatır.

OleDbDataAdapter(OleDbCommand)

özelliği olarak belirtilen OleDbCommand sınıfın OleDbDataAdapter yeni bir örneğini SelectCommand başlatır.

OleDbDataAdapter(String, OleDbConnection)

ile SelectCommandsınıfının yeni bir örneğini OleDbDataAdapter başlatır.

OleDbDataAdapter(String, String)

ile SelectCommandsınıfının yeni bir örneğini OleDbDataAdapter başlatır.

OleDbDataAdapter()

Kaynak:
OleDbDataAdapter.cs
Kaynak:
OleDbDataAdapter.cs
Kaynak:
OleDbDataAdapter.cs

OleDbDataAdapter sınıfının yeni bir örneğini başlatır.

public:
 OleDbDataAdapter();
public OleDbDataAdapter ();
Public Sub New ()

Örnekler

Aşağıdaki örnek bir OleDbDataAdapter oluşturur ve bazı özelliklerini ayarlar.

public static OleDbDataAdapter CreateDataAdapter(
    OleDbConnection connection)
{
    string selectCommand =
        "SELECT CustomerID, CompanyName FROM Customers";
    OleDbDataAdapter adapter =
        new OleDbDataAdapter(selectCommand, connection);

    adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;

    // Create the Insert, Update and Delete commands.
    adapter.InsertCommand = new OleDbCommand(
        "INSERT INTO Customers (CustomerID, CompanyName) " +
        "VALUES (?, ?)");

    adapter.UpdateCommand = new OleDbCommand(
        "UPDATE Customers SET CustomerID = ?, CompanyName = ? " +
        "WHERE CustomerID = ?");

    adapter.DeleteCommand = new OleDbCommand(
        "DELETE FROM Customers WHERE CustomerID = ?");

    // Create the parameters.
    adapter.InsertCommand.Parameters.Add("@CustomerID",
        OleDbType.Char, 5, "CustomerID");
    adapter.InsertCommand.Parameters.Add("@CompanyName",
        OleDbType.VarChar, 40, "CompanyName");

    adapter.UpdateCommand.Parameters.Add("@CustomerID",
        OleDbType.Char, 5, "CustomerID");
    adapter.UpdateCommand.Parameters.Add("@CompanyName",
        OleDbType.VarChar, 40, "CompanyName");
    adapter.UpdateCommand.Parameters.Add("@oldCustomerID",
        OleDbType.Char, 5, "CustomerID").SourceVersion =
        DataRowVersion.Original;

    adapter.DeleteCommand.Parameters.Add("@CustomerID",
        OleDbType.Char, 5, "CustomerID").SourceVersion =
        DataRowVersion.Original;

    return adapter;
}
Public Function CreateDataAdapter( _
    ByVal connection As OleDbConnection) As OleDbDataAdapter

    Dim selectCommand As String = _
        "SELECT CustomerID, CompanyName FROM Customers"
    Dim adapter As OleDbDataAdapter = _
        New OleDbDataAdapter(selectCommand, connection)

    adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey

    ' Create the commands.
    adapter.InsertCommand = New OleDbCommand( _
        "INSERT INTO Customers (CustomerID, CompanyName) " & _
         "VALUES (?, ?)")

    adapter.UpdateCommand = New OleDbCommand( _
        "UPDATE Customers SET CustomerID = ?, CompanyName = ? " & _
        "WHERE CustomerID = ?")

    adapter.DeleteCommand = New OleDbCommand( _
        "DELETE FROM Customers WHERE CustomerID = ?")

    ' Create the parameters.
    adapter.InsertCommand.Parameters.Add( _
        "@CustomerID", OleDbType.Char, 5, "CustomerID")
    adapter.InsertCommand.Parameters.Add( _
        "@CompanyName", OleDbType.VarChar, 40, "CompanyName")

    adapter.UpdateCommand.Parameters.Add( _
        "@CustomerID", OleDbType.Char, 5, "CustomerID")
    adapter.UpdateCommand.Parameters.Add( _
        "@CompanyName", OleDbType.VarChar, 40, "CompanyName")
    adapter.UpdateCommand.Parameters.Add( _
        "@oldCustomerID", OleDbType.Char, 5, "CustomerID").SourceVersion = _
        DataRowVersion.Original

    adapter.DeleteCommand.Parameters.Add( _
        "@CustomerID", OleDbType.Char, 5, "CustomerID").SourceVersion = _
        DataRowVersion.Original

    Return adapter
End Function

Açıklamalar

örneğini OleDbDataAdapteroluşturduğunuzda, aşağıdaki okuma/yazma özellikleri aşağıdaki başlangıç değerlerine ayarlanır.

Özellikler İlk değer
MissingMappingAction MissingMappingAction.Passthrough
MissingSchemaAction MissingSchemaAction.Add

Özelliğine ayrı bir çağrı aracılığıyla bu özelliklerden herhangi birinin değerini değiştirebilirsiniz.

Ayrıca bkz.

Şunlara uygulanır

OleDbDataAdapter(OleDbCommand)

Kaynak:
OleDbDataAdapter.cs
Kaynak:
OleDbDataAdapter.cs
Kaynak:
OleDbDataAdapter.cs

özelliği olarak belirtilen OleDbCommand sınıfın OleDbDataAdapter yeni bir örneğini SelectCommand başlatır.

public:
 OleDbDataAdapter(System::Data::OleDb::OleDbCommand ^ selectCommand);
public OleDbDataAdapter (System.Data.OleDb.OleDbCommand? selectCommand);
public OleDbDataAdapter (System.Data.OleDb.OleDbCommand selectCommand);
new System.Data.OleDb.OleDbDataAdapter : System.Data.OleDb.OleDbCommand -> System.Data.OleDb.OleDbDataAdapter
Public Sub New (selectCommand As OleDbCommand)

Parametreler

selectCommand
OleDbCommand

SELECT OleDbCommand deyimi veya saklı yordam olan ve özelliği OleDbDataAdapterolarak SelectCommand ayarlanmış bir .

Örnekler

Aşağıdaki örnek bir OleDbDataAdapter oluşturur ve bazı özelliklerini ayarlar.

public static OleDbDataAdapter CreateDataAdapter(string selectCommand,
    OleDbConnection connection)
{
    OleDbDataAdapter adapter = new OleDbDataAdapter(selectCommand, connection);

    adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;

    // Create the Insert, Update and Delete commands.
    adapter.InsertCommand = new OleDbCommand(
        "INSERT INTO Customers (CustomerID, CompanyName) " +
        "VALUES (?, ?)");

    adapter.UpdateCommand = new OleDbCommand(
        "UPDATE Customers SET CustomerID = ?, CompanyName = ? " +
        "WHERE CustomerID = ?");

    adapter.DeleteCommand = new OleDbCommand(
        "DELETE FROM Customers WHERE CustomerID = ?");

    // Create the parameters.
    adapter.InsertCommand.Parameters.Add("@CustomerID",
        OleDbType.Char, 5, "CustomerID");
    adapter.InsertCommand.Parameters.Add("@CompanyName",
        OleDbType.VarChar, 40, "CompanyName");

    adapter.UpdateCommand.Parameters.Add("@CustomerID",
        OleDbType.Char, 5, "CustomerID");
    adapter.UpdateCommand.Parameters.Add("@CompanyName",
        OleDbType.VarChar, 40, "CompanyName");
    adapter.UpdateCommand.Parameters.Add("@oldCustomerID",
        OleDbType.Char, 5, "CustomerID").SourceVersion =
        DataRowVersion.Original;

    adapter.DeleteCommand.Parameters.Add("@CustomerID",
        OleDbType.Char, 5, "CustomerID").SourceVersion =
        DataRowVersion.Original;

    return adapter;
}
Public Function CreateDataAdapter(ByVal selectCommand As String, _
    ByVal connection As OleDbConnection) As OleDbDataAdapter

    Dim adapter As OleDbDataAdapter = _
        New OleDbDataAdapter(selectCommand, connection)

    adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey

    ' Create the commands.
    adapter.InsertCommand = New OleDbCommand( _
        "INSERT INTO Customers (CustomerID, CompanyName) " & _
         "VALUES (?, ?)")

    adapter.UpdateCommand = New OleDbCommand( _
        "UPDATE Customers SET CustomerID = ?, CompanyName = ? " & _
        "WHERE CustomerID = ?")

    adapter.DeleteCommand = New OleDbCommand( _
        "DELETE FROM Customers WHERE CustomerID = ?")

    ' Create the parameters.
    adapter.InsertCommand.Parameters.Add( _
        "@CustomerID", OleDbType.Char, 5, "CustomerID")
    adapter.InsertCommand.Parameters.Add( _
        "@CompanyName", OleDbType.VarChar, 40, "CompanyName")

    adapter.UpdateCommand.Parameters.Add( _
        "@CustomerID", OleDbType.Char, 5, "CustomerID")
    adapter.UpdateCommand.Parameters.Add( _
        "@CompanyName", OleDbType.VarChar, 40, "CompanyName")
    adapter.UpdateCommand.Parameters.Add( _
        "@oldCustomerID", OleDbType.Char, 5, "CustomerID").SourceVersion = _
        DataRowVersion.Original

    adapter.DeleteCommand.Parameters.Add( _
        "@CustomerID", OleDbType.Char, 5, "CustomerID").SourceVersion = _
        DataRowVersion.Original

    Return adapter
End Function

Açıklamalar

Oluşturucunun OleDbDataAdapter bu uygulaması, özelliğini parametresinde belirtilen değere selectCommand ayarlarSelectCommand.

örneğini OleDbDataAdapteroluşturduğunuzda, aşağıdaki okuma/yazma özellikleri aşağıdaki başlangıç değerlerine ayarlanır.

Özellikler İlk değer
MissingMappingAction MissingMappingAction.Passthrough
MissingSchemaAction MissingSchemaAction.Add

Özelliğine ayrı bir çağrı aracılığıyla bu özelliklerden herhangi birinin değerini değiştirebilirsiniz.

Ayrıca bkz.

Şunlara uygulanır

OleDbDataAdapter(String, OleDbConnection)

Kaynak:
OleDbDataAdapter.cs
Kaynak:
OleDbDataAdapter.cs
Kaynak:
OleDbDataAdapter.cs

ile SelectCommandsınıfının yeni bir örneğini OleDbDataAdapter başlatır.

public:
 OleDbDataAdapter(System::String ^ selectCommandText, System::Data::OleDb::OleDbConnection ^ selectConnection);
public OleDbDataAdapter (string? selectCommandText, System.Data.OleDb.OleDbConnection? selectConnection);
public OleDbDataAdapter (string selectCommandText, System.Data.OleDb.OleDbConnection selectConnection);
new System.Data.OleDb.OleDbDataAdapter : string * System.Data.OleDb.OleDbConnection -> System.Data.OleDb.OleDbDataAdapter
Public Sub New (selectCommandText As String, selectConnection As OleDbConnection)

Parametreler

selectCommandText
String

özelliği OleDbDataAdaptertarafından SelectCommand kullanılacak bir SQL SELECT deyimi veya saklı yordam olan bir dize.

selectConnection
OleDbConnection

OleDbConnection Bağlantıyı temsil eden bir.

Örnekler

Aşağıdaki örnek bir OleDbDataAdapter oluşturur ve bazı özelliklerini ayarlar.

public static OleDbDataAdapter CreateDataAdapter(
    OleDbConnection connection)
{
    string selectCommand =
        "SELECT CustomerID, CompanyName FROM Customers";
    OleDbDataAdapter adapter =
        new OleDbDataAdapter(selectCommand, connection);

    adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;

    // Create the Insert, Update and Delete commands.
    adapter.InsertCommand = new OleDbCommand(
        "INSERT INTO Customers (CustomerID, CompanyName) " +
        "VALUES (?, ?)");

    adapter.UpdateCommand = new OleDbCommand(
        "UPDATE Customers SET CustomerID = ?, CompanyName = ? " +
        "WHERE CustomerID = ?");

    adapter.DeleteCommand = new OleDbCommand(
        "DELETE FROM Customers WHERE CustomerID = ?");

    // Create the parameters.
    adapter.InsertCommand.Parameters.Add("@CustomerID",
        OleDbType.Char, 5, "CustomerID");
    adapter.InsertCommand.Parameters.Add("@CompanyName",
        OleDbType.VarChar, 40, "CompanyName");

    adapter.UpdateCommand.Parameters.Add("@CustomerID",
        OleDbType.Char, 5, "CustomerID");
    adapter.UpdateCommand.Parameters.Add("@CompanyName",
        OleDbType.VarChar, 40, "CompanyName");
    adapter.UpdateCommand.Parameters.Add("@oldCustomerID",
        OleDbType.Char, 5, "CustomerID").SourceVersion =
        DataRowVersion.Original;

    adapter.DeleteCommand.Parameters.Add("@CustomerID",
        OleDbType.Char, 5, "CustomerID").SourceVersion =
        DataRowVersion.Original;

    return adapter;
}
Public Function CreateDataAdapter( _
    ByVal connection As OleDbConnection) As OleDbDataAdapter

    Dim selectCommand As String = _
        "SELECT CustomerID, CompanyName FROM Customers"
    Dim adapter As OleDbDataAdapter = _
        New OleDbDataAdapter(selectCommand, connection)

    adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey

    ' Create the commands.
    adapter.InsertCommand = New OleDbCommand( _
        "INSERT INTO Customers (CustomerID, CompanyName) " & _
         "VALUES (?, ?)")

    adapter.UpdateCommand = New OleDbCommand( _
        "UPDATE Customers SET CustomerID = ?, CompanyName = ? " & _
        "WHERE CustomerID = ?")

    adapter.DeleteCommand = New OleDbCommand( _
        "DELETE FROM Customers WHERE CustomerID = ?")

    ' Create the parameters.
    adapter.InsertCommand.Parameters.Add( _
        "@CustomerID", OleDbType.Char, 5, "CustomerID")
    adapter.InsertCommand.Parameters.Add( _
        "@CompanyName", OleDbType.VarChar, 40, "CompanyName")

    adapter.UpdateCommand.Parameters.Add( _
        "@CustomerID", OleDbType.Char, 5, "CustomerID")
    adapter.UpdateCommand.Parameters.Add( _
        "@CompanyName", OleDbType.VarChar, 40, "CompanyName")
    adapter.UpdateCommand.Parameters.Add( _
        "@oldCustomerID", OleDbType.Char, 5, "CustomerID").SourceVersion = _
        DataRowVersion.Original

    adapter.DeleteCommand.Parameters.Add( _
        "@CustomerID", OleDbType.Char, 5, "CustomerID").SourceVersion = _
        DataRowVersion.Original

    Return adapter
End Function

Açıklamalar

Uygulamasının OleDbDataAdapter bu uygulaması açılır ve henüz açık değilse kapatır OleDbConnection . Bu, iki veya daha fazla OleDbDataAdapter nesne için yöntemini çağırması Fill gereken bir uygulamada yararlı olabilir. OleDbConnection zaten açıksa, kapatmak için açıkça çağrısı Close veya Dispose gerekir.

örneğini OleDbDataAdapteroluşturduğunuzda, aşağıdaki okuma/yazma özellikleri aşağıdaki başlangıç değerlerine ayarlanır.

Özellikler İlk değer
MissingMappingAction MissingMappingAction.Passthrough
MissingSchemaAction MissingSchemaAction.Add

Özelliğine ayrı bir çağrı aracılığıyla bu özelliklerden birinin değerini değiştirebilirsiniz.

Ayrıca bkz.

Şunlara uygulanır

OleDbDataAdapter(String, String)

Kaynak:
OleDbDataAdapter.cs
Kaynak:
OleDbDataAdapter.cs
Kaynak:
OleDbDataAdapter.cs

ile SelectCommandsınıfının yeni bir örneğini OleDbDataAdapter başlatır.

public:
 OleDbDataAdapter(System::String ^ selectCommandText, System::String ^ selectConnectionString);
public OleDbDataAdapter (string? selectCommandText, string? selectConnectionString);
public OleDbDataAdapter (string selectCommandText, string selectConnectionString);
new System.Data.OleDb.OleDbDataAdapter : string * string -> System.Data.OleDb.OleDbDataAdapter
Public Sub New (selectCommandText As String, selectConnectionString As String)

Parametreler

selectCommandText
String

özelliği OleDbDataAdaptertarafından SelectCommand kullanılacak bir SQL SELECT deyimi veya saklı yordam olan bir dize.

selectConnectionString
String

Bağlantı dizesi.

Örnekler

Aşağıdaki örnek bir OleDbDataAdapter oluşturur ve bazı özelliklerini ayarlar.

public static OleDbDataAdapter CreateDataAdapter(
    OleDbConnection connection)
{
    string selectCommand =
        "SELECT CustomerID, CompanyName FROM Customers";
    OleDbDataAdapter adapter =
        new OleDbDataAdapter(selectCommand, connection);

    adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;

    // Create the Insert, Update and Delete commands.
    adapter.InsertCommand = new OleDbCommand(
        "INSERT INTO Customers (CustomerID, CompanyName) " +
        "VALUES (?, ?)");

    adapter.UpdateCommand = new OleDbCommand(
        "UPDATE Customers SET CustomerID = ?, CompanyName = ? " +
        "WHERE CustomerID = ?");

    adapter.DeleteCommand = new OleDbCommand(
        "DELETE FROM Customers WHERE CustomerID = ?");

    // Create the parameters.
    adapter.InsertCommand.Parameters.Add("@CustomerID",
        OleDbType.Char, 5, "CustomerID");
    adapter.InsertCommand.Parameters.Add("@CompanyName",
        OleDbType.VarChar, 40, "CompanyName");

    adapter.UpdateCommand.Parameters.Add("@CustomerID",
        OleDbType.Char, 5, "CustomerID");
    adapter.UpdateCommand.Parameters.Add("@CompanyName",
        OleDbType.VarChar, 40, "CompanyName");
    adapter.UpdateCommand.Parameters.Add("@oldCustomerID",
        OleDbType.Char, 5, "CustomerID").SourceVersion =
        DataRowVersion.Original;

    adapter.DeleteCommand.Parameters.Add("@CustomerID",
        OleDbType.Char, 5, "CustomerID").SourceVersion =
        DataRowVersion.Original;

    return adapter;
}
Public Function CreateDataAdapter( _
    ByVal connection As OleDbConnection) As OleDbDataAdapter

    Dim selectCommand As String = _
        "SELECT CustomerID, CompanyName FROM Customers"
    Dim adapter As OleDbDataAdapter = _
        New OleDbDataAdapter(selectCommand, connection)

    adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey

    ' Create the commands.
    adapter.InsertCommand = New OleDbCommand( _
        "INSERT INTO Customers (CustomerID, CompanyName) " & _
         "VALUES (?, ?)")

    adapter.UpdateCommand = New OleDbCommand( _
        "UPDATE Customers SET CustomerID = ?, CompanyName = ? " & _
        "WHERE CustomerID = ?")

    adapter.DeleteCommand = New OleDbCommand( _
        "DELETE FROM Customers WHERE CustomerID = ?")

    ' Create the parameters.
    adapter.InsertCommand.Parameters.Add( _
        "@CustomerID", OleDbType.Char, 5, "CustomerID")
    adapter.InsertCommand.Parameters.Add( _
        "@CompanyName", OleDbType.VarChar, 40, "CompanyName")

    adapter.UpdateCommand.Parameters.Add( _
        "@CustomerID", OleDbType.Char, 5, "CustomerID")
    adapter.UpdateCommand.Parameters.Add( _
        "@CompanyName", OleDbType.VarChar, 40, "CompanyName")
    adapter.UpdateCommand.Parameters.Add( _
        "@oldCustomerID", OleDbType.Char, 5, "CustomerID").SourceVersion = _
        DataRowVersion.Original

    adapter.DeleteCommand.Parameters.Add( _
        "@CustomerID", OleDbType.Char, 5, "CustomerID").SourceVersion = _
        DataRowVersion.Original

    Return adapter
End Function

Açıklamalar

Oluşturucunun OleDbDataAdapter bu aşırı yüklemesi, özelliğini ayarlamak için parametresini SelectCommand kullanırselectConnectionString. Ancak, bağlantıyı açmaz. Yine de bağlantıyı açıkça açmanız gerekir.

örneğini OleDbDataAdapteroluşturduğunuzda, aşağıdaki okuma/yazma özellikleri aşağıdaki başlangıç değerlerine ayarlanır.

Özellikler İlk değer
MissingMappingAction MissingMappingAction.Passthrough
MissingSchemaAction MissingSchemaAction.Add

Özelliğine ayrı bir çağrı aracılığıyla bu özelliklerden herhangi birinin değerini değiştirebilirsiniz.

Ayrıca bkz.

Şunlara uygulanır