public bool executeInsert(ExecutableQuery query) { NpgsqlCommand command = new NpgsqlCommand(query.getQuery(), conn); int status = 0; bool result = false; try { status = command.ExecuteNonQuery(); } catch (NpgsqlException e) { MessageBox.Show("Błąd: " + e.BaseMessage + "\n\n" + query.getQuery(), "ErrorMessage"); } finally { result = (status > 0); } return result; }
public NpgsqlDataReader executeQuery(ExecutableQuery query) { NpgsqlCommand command = new NpgsqlCommand(query.getQuery(), conn); NpgsqlDataReader dr = null; try { dr = command.ExecuteReader(); } catch (NpgsqlException e) { //MessageBox.Show("Błąd: " + e.BaseMessage + "\n\n" + query.getQuery(), "ErrorMessage"); MessageBox.Show("Niepoprawne dane."); } return dr; }