Export (0) Print
Expand All

OracleDataAdapter Constructor (OracleCommand)

.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 with the specified SQL SELECT statement.

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

Parameters

selectCommand
An OracleCommand that is an SQL SELECT statement or stored procedure, and is set as the SelectCommand property of the OracleDataAdapter.

Remarks

This implementation of the OracleDataAdapter constructor sets the SelectCommand property to the value specified in the selectCommand parameter.

When you create an instance of OracleDataAdapter, the following read/write properties are set to their default values, as shown in the table.

Properties Initial Value
MissingMappingAction MissingMappingAction.Passthrough
MissingSchemaAction MissingSchemaAction.Add

You can change the value of any of these properties through a separate call to the property.

Example

[Visual Basic, C#, C++] 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 myOracleCommand As OracleCommand = New OracleCommand("SELECT DeptNo, DName FROM Dept", myOracleConnection)
    Dim custDA As OracleDataAdapter = New OracleDataAdapter(myOracleCommand)
    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");
    OracleCommand myOracleCommand = new OracleCommand("SELECT DeptNo, DName FROM Dept", myOracleConnection);
    OracleDataAdapter custDA = new OracleDataAdapter(myOracleCommand);
    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() 
{
    OracleConnection* myOracleConnection = new OracleConnection(S"Data Source=Oracle8i;Integrated Security=yes");
    OracleCommand* myOracleCommand = new OracleCommand(S"SELECT DeptNo, DName FROM Dept", myOracleConnection);
    OracleDataAdapter* custDA = new OracleDataAdapter(myOracleCommand);
    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.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

.NET Framework Security: 

See Also

OracleDataAdapter Class | OracleDataAdapter Members | System.Data.OracleClient Namespace | OracleDataAdapter Constructor Overload List

Show:
© 2014 Microsoft