Problem inserting into table in Postgresql

2

When I'm going to make a INSERT :

INSERT INTO categoria (cat_descricao,cat_status) VALUES ('não' ,'1' )

by passing some element with accentuation the following error occurs

  

ERROR: 22021: invalid byte sequence for encoding "UTF8": 0xe3 0x6f 0x27 >

But if I do the SQL statement on the SGBD itself, it goes normal with no problem, but when I return that information through DataTable it also appears with changed values. I'm using PostGres and C#

public int ExecutarSQL(string sSQL)
{
    int iLinhas = 0;
    if (ConectaBanco())
    {
        _comando.CommandText = sSQL;
        iLinhas = _comando.ExecuteNonQuery();
        DesconectaBanco();
    }
    return iLinhas;
}

When performing this function the error occurs in ExecuteNonQuery , apparently appears to be a UTF error, but the bank then accepts the problem is in the language? what action can be taken to resolve this problem?

    
asked by anonymous 14.12.2016 / 14:09

1 answer

3

Change the encondig to latin1 with the command below:

update pg_database set encoding = pg_char_to_encoding('LATIN1') 
where datname = 'nomedoBanco';
    
14.12.2016 / 14:18