using Oracle.ManagedDataAccess.Client; using System.Threading.Tasks; public async TaskUpdateEmployeeSalaryAsync(string connectionString, int employeeId, decimal newSalary) { using (OracleConnection connection = new OracleConnection(connectionString)) { await connection.OpenAsync(); using (OracleCommand command = connection.CreateCommand()) { command.CommandText = "UPDATE EMPLOYEES SET SALARY = :newSalary WHERE EMPLOYEE_ID = :employeeId"; command.Parameters.Add("newSalary", OracleDbType.Decimal).Value = newSalary; command.Parameters.Add("employeeId", OracleDbType.Int32).Value = employeeId; return await command.ExecuteNonQueryAsync(); } } }
using Oracle.ManagedDataAccess.Client; using System.Threading.Tasks; public async TaskThis example demonstrates how to use OracleCommand.ExecuteNonQueryAsync to delete inactive employees from the EMPLOYEES table of an Oracle database. The method takes a connection string as a parameter, opens a connection to the database asynchronously, creates an OracleCommand object with a SQL statement, and executes the statement asynchronously. The method returns the number of rows affected by the delete. Package library: Oracle.ManagedDataAccess.DeleteInactiveEmployeesAsync(string connectionString) { using (OracleConnection connection = new OracleConnection(connectionString)) { await connection.OpenAsync(); using (OracleCommand command = connection.CreateCommand()) { command.CommandText = "DELETE FROM EMPLOYEES WHERE STATUS = 'Inactive'"; return await command.ExecuteNonQueryAsync(); } } }