Export (0) Print
Expand All

OracleDataAdapter Constructor (String, OracleConnection)

Initializes a new instance of the OracleDataAdapter class with an SQL SELECT statement and an OracleConnection.

Namespace:  System.Data.OracleClient
Assembly:  System.Data.OracleClient (in System.Data.OracleClient.dll)

new : 
        selectCommandText:string * 
        selectConnection:OracleConnection -> OracleDataAdapter

Parameters

selectCommandText
Type: System.String

A string that is an SQL SELECT statement or stored procedure to be used by the SelectCommand property of the OracleDataAdapter.

selectConnection
Type: System.Data.OracleClient.OracleConnection

An OracleConnection that represents the connection.

This implementation of the OracleDataAdapter can be useful in an application that must call the Fill method for two or more OracleDataAdapter objects.

The following example creates an OracleDataAdapter and sets some of its properties.

[Visual Basic]

Public Sub CreateOracleDataAdapter()
    Dim myOracleConnection As OracleConnection = New OracleConnection("Data Source=Oracle8i;Integrated Security=yes")
    Dim mySelectText As String = "SELECT DeptNo, DName FROM Dept"
    Dim custDA As OracleDataAdapter = New OracleDataAdapter(mySelectText, myOracleConnection) 
    custDA.MissingSchemaAction = MissingSchemaAction.AddWithKey
   
    custDA.InsertCommand = New OracleCommand("INSERT INTO Dept (DeptNo, DName) " & _
                                            "VALUES (:pDeptNo, :pDName)", myOracleConnection)
    custDA.UpdateCommand = New OracleCommand("UPDATE Dept SET DeptNo = :pDeptNo, DName = :pDName " & _
                                            "WHERE DeptNo = :pDeptNo", myOracleConnection)
    custDA.DeleteCommand = New OracleCommand("DELETE FROM Dept WHERE DeptNo = :pDeptNo", myOracleConnection)

    custDA.InsertCommand.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo")
    custDA.InsertCommand.Parameters.Add("pDName", OracleType.VarChar, 14, "DName")
 
    custDA.UpdateCommand.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo")
    custDA.UpdateCommand.Parameters.Add("pDName", OracleType.VarChar, 14, "DName")
    custDA.UpdateCommand.Parameters.Add("poldDeptNo", OracleType.Number, 2, "DeptNo").SourceVersion = DataRowVersion.Original

    custDA.DeleteCommand.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo").SourceVersion = DataRowVersion.Original
End Sub

[C#]

public static void CreateOracleDataAdapter() 
{
    OracleConnection myOracleConnection = new OracleConnection("Data Source=Oracle8i;Integrated Security=yes");

    string mySelectText = "SELECT DeptNo, DName FROM Dept";

    OracleDataAdapter custDA = new OracleDataAdapter(mySelectText, myOracleConnection );
    custDA.MissingSchemaAction = MissingSchemaAction.AddWithKey;
   
    custDA.InsertCommand = new OracleCommand("INSERT INTO Dept (DeptNo, DName) " +
                                            "VALUES (:pDeptNo, :pDName)", myOracleConnection);
    custDA.UpdateCommand = new OracleCommand("UPDATE Dept SET DeptNo = :pDeptNo, DName = :pDName " +
                                            "WHERE DeptNo = :pDeptNo", myOracleConnection);
    custDA.DeleteCommand = new OracleCommand("DELETE FROM Dept WHERE DeptNo = :pDeptNo", myOracleConnection);

    custDA.InsertCommand.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo");
    custDA.InsertCommand.Parameters.Add("pDName", OracleType.VarChar, 14, "DName");
 
    custDA.UpdateCommand.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo");
    custDA.UpdateCommand.Parameters.Add("pDName", OracleType.VarChar, 14, "DName");
    custDA.UpdateCommand.Parameters.Add("poldDeptNo", OracleType.Number, 2, "DeptNo").SourceVersion = DataRowVersion.Original;

    custDA.DeleteCommand.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo").SourceVersion = DataRowVersion.Original;
}

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft