public void updateMessage ( Message message) { string sql = "UPDATE `SmsApplicatie`.`messages` " + "SET numberReceiver=:numberReceiver, message=:message, sendAt=:sendAt, contactId=:contactId" + "where id=:id"; MySqlCommand statement = this.databaseConnection.CreateCommand (); statement.CommandText = sql; statement.Prepare (); statement.Parameters.AddWithValue ( "numberReceiver", message.getNumberReceiver() ); statement.Parameters.AddWithValue ( "message", message.getMessageBody() ); statement.Parameters.AddWithValue ( "sendAt", message.getSendAt() ); statement.Parameters.AddWithValue ( "contactId", message.getContactId() ); statement.Parameters.AddWithValue ( "id", message.getId() ); }
public void insertMessege ( Message message) { string sql = "INSERT INTO `SmsApplicatie`.`messages`( numberReceiver, message, sendAt, contactId ) " + "VALUES ( :numberReceiver, :message, :sendAt, :contactId )"; MySqlCommand statement = this.databaseConnection.CreateCommand (); statement.CommandText = sql; statement.Prepare (); statement.Parameters.AddWithValue ( "numberReceiver", message.getNumberReceiver() ); statement.Parameters.AddWithValue ("message", message.getMessageBody () ); statement.Parameters.AddWithValue ("sendAt", Convert.ToString (message.getSendAt ())); statement.Parameters.AddWithValue ("contactId", message.getContactId ()); if ( statement.ExecuteNonQuery () == 0 ){ throw new ApplicationException (); } }