Export (0) Print
Expand All

OracleDataAdapter Constructor

.NET Framework 1.1
Note: This namespace, class, or member is supported only in version 1.1 of the .NET Framework.

Initializes a new instance of the OracleDataAdapter class.

Overload List

Initializes a new instance of the OracleDataAdapter class.

[Visual Basic] Public Sub New()
[C#] public OracleDataAdapter();
[C++] public: OracleDataAdapter();
[JScript] public function OracleDataAdapter();

Initializes a new instance of the OracleDataAdapter class with the specified SQL SELECT statement.

[Visual Basic] Public Sub New(OracleCommand)
[C#] public OracleDataAdapter(OracleCommand);
[C++] public: OracleDataAdapter(OracleCommand*);
[JScript] public function OracleDataAdapter(OracleCommand);

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

[Visual Basic] Public Sub New(String, OracleConnection)
[C#] public OracleDataAdapter(string, OracleConnection);
[C++] public: OracleDataAdapter(String*, OracleConnection*);
[JScript] public function OracleDataAdapter(String, OracleConnection);

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

[Visual Basic] Public Sub New(String, String)
[C#] public OracleDataAdapter(string, string);
[C++] public: OracleDataAdapter(String*, String*);
[JScript] public function OracleDataAdapter(String, String);

Example

[Visual Basic, C#, C++] The following example creates an OracleDataAdapter and sets some of its properties.

[Visual Basic, C#, C++] Note   This example shows how to use one of the overloaded versions of the OracleDataAdapter constructor. For other examples that might be available, see the individual overload topics.
[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;
}


[C++] 
public:
static void CreateOracleDataAdapter() 
{
    String* myConnectionText = S"Data Source=Oracle8i;Integrated Security=yes";

    String* mySelectText = S"SELECT DeptNo, DName FROM Dept";

    OracleDataAdapter* custDA = new OracleDataAdapter(mySelectText, myConnectionText );
    OracleConnection* myOracleConnection = custDA->SelectCommand->Connection;

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

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

    custDA->DeleteCommand->Parameters->Add(S"pDeptNo", OracleType::Number, 2, S"DeptNo")->SourceVersion = DataRowVersion::Original;
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

OracleDataAdapter Class | OracleDataAdapter Members | System.Data.OracleClient Namespace

Show:
© 2014 Microsoft