Export (0) Print
Expand All
1 out of 3 rated this helpful - Rate this topic

OracleDataAdapter.SelectCommand Property

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

Gets or sets an SQL statement or stored procedure used to select records in the database.

[Visual Basic]
Public Shadows Property SelectCommand As OracleCommand
[C#]
public new OracleCommand SelectCommand {get; set;}
[C++]
public: __property OracleCommand* get_SelectCommand();
public: __property void set_SelectCommand(OracleCommand*);
[JScript]
public hide function get SelectCommand() : OracleCommand;
public function set SelectCommand(OracleCommand);

Property Value

An OracleCommand that is used during a fill operation to select records from database for placement in the DataSet.

Remarks

When SelectCommand is assigned to a previously created OracleCommand, the OracleCommand is not cloned. Instead, the SelectCommand maintains a reference to the previously created OracleCommand object.

If SelectCommand does not return any rows, no tables are added to the DataSet, and no exception is raised.

Example

[Visual Basic, C#, C++] The following example creates an OracleDataAdapter and sets the SelectCommand and InsertCommand properties. It assumes you have already created an OracleConnection object.

[Visual Basic] 
Public Shared Function CreateCustomerAdapter(conn As OracleConnection) As OracleDataAdapter 
  
  Dim da As OracleDataAdapter = New OracleDataAdapter()
  Dim cmd As OracleCommand

  ' Create the SelectCommand.

  cmd = New OracleCommand("SELECT * FROM Dept " & _
                       "WHERE DName = :pDName AND Loc = :pLoc", conn)

  cmd.Parameters.Add("pDName", OracleType.NVarChar, 14)
  cmd.Parameters.Add("pLoc", OracleType.NVarChar, 13)

  da.SelectCommand = cmd

  ' Create the InsertCommand.

  cmd = New OracleCommand("INSERT INTO Dept (DeptNo, DName) " & _
                       "VALUES (pDeptNo, pDName)", conn)

  cmd.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo")
  cmd.Parameters.Add("pDName", OracleType.NVarChar, 14, "DName")

  da.InsertCommand = cmd

  Return da
End Function

[C#] 
public static OracleDataAdapter CreateCustomerAdapter(OracleConnection conn)
{
  OracleDataAdapter da = new OracleDataAdapter();
  OracleCommand cmd;

  // Create the SelectCommand.

  cmd = new OracleCommand("SELECT * FROM Dept " +
                       "WHERE DName = :pDName AND Loc = :pLoc", conn);

  cmd.Parameters.Add("pDName", OracleType.NVarChar, 14);
  cmd.Parameters.Add("pLoc", OracleType.NVarChar, 13);

  da.SelectCommand = cmd;

  // Create the InsertCommand.

  cmd = new OracleCommand("INSERT INTO Dept (DeptNo, DName) " +
                       "VALUES (:pDeptNo, :pDName)", conn);

  cmd.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo");
  cmd.Parameters.Add("pDName", OracleType.NVarChar, 14, "DName");

  da.InsertCommand = cmd;

  return da;
}

[C++] 
public:
static OracleDataAdapter* CreateCustomerAdapter(OracleConnection* conn)
{
  OracleDataAdapter* da = new OracleDataAdapter();
  OracleCommand* cmd;

  // Create the SelectCommand.

  cmd = new OracleCommand(S"SELECT * FROM Dept " 
                          S"WHERE DName = :pDName AND Loc = :pLoc", conn);

  cmd->Parameters->Add(S"pDName", OracleType::NVarChar, 14);
  cmd->Parameters->Add(S"pLoc", OracleType::NVarChar, 13);

  da->SelectCommand = cmd;

  // Create the InsertCommand.

  cmd = new OracleCommand(S"INSERT INTO Dept (DeptNo, DName) " 
                          S"VALUES (:pDeptNo, :pDName)", conn);

  cmd->Parameters->Add(S"pDeptNo", OracleType::Number, 2, S"DeptNo");
  cmd->Parameters->Add(S"pDName", OracleType::NVarChar, 14, S"DName");

  da->InsertCommand = cmd;

  return da;
}

[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 | DeleteCommand | InsertCommand | UpdateCommand

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.