private static ExecuteBlind ( |
||
connector | ||
query | ||
timeout | int | |
return | void |
using (NpgsqlConnection connection = new NpgsqlConnection(connectionString)) { connection.Open(); using (NpgsqlCommand command = new NpgsqlCommand("UPDATE my_table SET column1 = @value WHERE id = @id", connection)) { command.Parameters.AddWithValue("@value", "new value"); command.Parameters.AddWithValue("@id", 1); int rowsAffected = command.ExecuteBlind(); Console.WriteLine("{0} rows affected", rowsAffected); } }
using (NpgsqlConnection connection = new NpgsqlConnection(connectionString)) { connection.Open(); using (NpgsqlCommand command = new NpgsqlCommand("DELETE FROM my_table WHERE id = @id", connection)) { command.Parameters.AddWithValue("@id", 1); int rowsAffected = command.ExecuteBlind(); Console.WriteLine("{0} rows affected", rowsAffected); } }In both cases, Npgsql package library is used.
private static ExecuteBlind ( |
||
connector | ||
query | ||
timeout | int | |
return | void |