Export (0) Print
Expand All

OracleDataAdapter.OracleDataAdapter(String, String) Constructor

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

Namespace: System.Data.OracleClient
Assembly: System.Data.OracleClient (in system.data.oracleclient.dll)

public:
OracleDataAdapter (
	String^ selectCommandText, 
	String^ selectConnectionString
)
public OracleDataAdapter (
	String selectCommandText, 
	String selectConnectionString
)
public function OracleDataAdapter (
	selectCommandText : String, 
	selectConnectionString : String
)
Not applicable.

Parameters

selectCommandText

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

selectConnectionString

The connection string.

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

[Visual Basic]

Public Sub CreateOracleDataAdapter()
    Dim myConnectionText As String = "Data Source=Oracle8i;Integrated Security=yes"
    Dim mySelectText As String = "SELECT DeptNo, DName FROM Dept"
    Dim custDA As OracleDataAdapter = New OracleDataAdapter(mySelectText, myConnectionText ) 
    Dim myOracleConnection As OracleConnection = custDA.SelectCommand.Connection

    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() 
{
    string myConnectionText = "Data Source=Oracle8i;Integrated Security=yes";

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

    OracleDataAdapter custDA = new OracleDataAdapter(mySelectText, myConnectionText );
   OracleConnection myOracleConnection = custDA.SelectCommand.Connection;

    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;
}

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1

Community Additions

ADD
Show:
© 2014 Microsoft