The System.Data.OracleClient package library in C# provides a variety of classes to access a Oracle database. One of these classes is OracleCommand, which is used to execute SQL statements against a database.
Example 1: Execute a SELECT statement and return a data reader
OracleCommand cmd = new OracleCommand("SELECT * FROM Customers", connection); OracleDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { // Process the data }
In this example, an OracleCommand object is created and passed a SELECT statement and a OracleConnection object. The ExecuteReader method is called on the command object, which returns an OracleDataReader object. The data reader is then used to retrieve and process the results of the query.
Example 2: Execute an INSERT statement and return the number of rows affected
OracleCommand cmd = new OracleCommand("INSERT INTO Customers (Name, Email) VALUES ('John Doe', '[email protected]')", connection); int rowsAffected = cmd.ExecuteNonQuery();
In this example, an OracleCommand object is created and passed an INSERT statement and a OracleConnection object. The ExecuteNonQuery method is called on the command object, which returns the number of rows affected by the query.
C# (CSharp) System.Data.OracleClient OracleCommand.ExecuteReader - 48 examples found. These are the top rated real world C# (CSharp) examples of System.Data.OracleClient.OracleCommand.ExecuteReader extracted from open source projects. You can rate examples to help us improve the quality of examples.