postgresqldevartdotconnect

Special characters insertion into PostgreSQL with dotConnectForPostgreSQL provider


As part of requirement, we have to insert special characters data into PostgreSQL table by using c# queries(ORM). Getting the error while committing the trasnaction.

"invalid byte sequence for encoding "UTF8": 0xc3 0x5f"

Special characters: Ã_Ã

Query: INSERT INTO XXXXXXX(key, file_name, file_path, source_id) VALUES (E'XXXX', E'Ã_Ã', ‘Ã_Ã.xlsx', XXX5)

.Net framwork 4.61. PostgreSQl 11 nHibernate C#


Solution

  • Please add "Unicode=true;" to your connection string. Refer to https://www.devart.com/dotconnect/postgresql/docs/?Devart.Data.PostgreSql~Devart.Data.PostgreSql.PgSqlConnection~ConnectionString.html.