public void updateContact ( Contact contact) { string sql = "UPDATE `SmsApplicatie`.`contact` " + "SET" + "telephoneNumber=:telephoneNumber," + "alias=:alias," + "firstName=:firstName," + "lastName=:lastName," + "emailAddress=:emailAddress WHERE id=:id"; MySqlCommand statement = databaseConnection.CreateCommand (); statement.CommandText = sql; statement.Prepare (); statement.Parameters.AddWithValue( "telephoneNumber", contact.getTelephoneNumber()); statement.Parameters.AddWithValue ( "alias", contact.getAlias()); statement.Parameters.AddWithValue ( "firstName", contact.getFirstName() ); statement.Parameters.AddWithValue ( "lastName", contact.getLastName() ); statement.Parameters.AddWithValue ( "emailAddress", contact.getEmailAddress() ); if ( statement.ExecuteNonQuery () == 0 ){ throw new ApplicationException (); } }
public void insertContact ( Contact contact) { string sql = "INSERT INTO `SmsApplicatie`.`contacts`(telephoneNumber, alias, firstName, lastName, emailAddress ) " + "VALUES :telephoneNumber, :alias, :firstName, :lastName, :emailAddress"; MySqlCommand statement = this.databaseConnection.CreateCommand (); statement.CommandText = sql; statement.Prepare (); statement.Parameters.AddWithValue ("telephoneNumber", contact.getTelephoneNumber ()); statement.Parameters.AddWithValue ("alias", contact.getAlias ()); statement.Parameters.AddWithValue ("firstName", contact.getFirstName ()); statement.Parameters.AddWithValue ("lastName", contact.getLastName ()); statement.Parameters.AddWithValue ("emailAddress", contact.getEmailAddress ()); if ( statement.ExecuteNonQuery () == 0 ){ throw new ApplicationException (); } }