Update data


The update is so easy when we know hot to insert and handle parameters.



        public void Update(string newcity, int city_id)
        {
            Npgsql.NpgsqlConnection oConn = new Npgsql.NpgsqlConnection("Server=192.168.10.4;Port=5432;Userid=postgres;Password=stefan;Protocol=3;SSL=false;Pooling=true;MinPoolSize=1;MaxPoolSize=20;Encoding=UNICODE;Timeout=15;SslMode=Disable;Database=pagila");
            oConn.Open();


            Npgsql.NpgsqlCommand command = new Npgsql.NpgsqlCommand("update city set city=:city where city_id=:city_id", oConn);

            command.Parameters.Add(new Npgsql.NpgsqlParameter("city", DbType.String, 50));
            command.Parameters.Add(new Npgsql.NpgsqlParameter("city_id", DbType.Int16));
            command.Parameters[0].Value = newcity;
            command.Parameters[1].Value = city_id;

            command.ExecuteNonQuery();

            oConn.Close();

        }