Esempio n. 1
0
        // public void Save()
        // {
        //   _instances.Add(_description);
        // }
        public void Edit(string newDescription)
        {
            MySqlConnection conn = DB.connection();

            conn.Open();
            var cmd = CreateCommand() as MySqlCommand;

            cmd.CommandText = @"UPDATE items SET description = @newDescription WHERE id = @searchid;";

            MySqlParameter searchid = new MySqlParameter();

            searchId.ParameterName = "@searchId";
            searchId.Value         = _id;
            cmd.Parameters.Add(searchId);

            MySqlParameter description = new MySqlParameter();

            description.Parameter = "@newDescription";
            description.Value     = newDescription;
            cmd.Parameters.Add(description);

            cmd.ExecuteNonQuery();
            _description = newDescription;

            conn.Close();
            if (conn ! = null)
            {
                conn.Dispose();
            }
        }