i'm using PostresSQLDirect for .NET2 and I've some problems with encoding.
Following a code sample witch causes the exception (the exception thrown is always the same “invalid byte sequence for encoding "UTF8": 0xe0a020”) :
Code: Select all
using (CoreLab.PostgreSql.PgSqlConnection cnn = new CoreLab.PostgreSql.PgSqlConnection())
{
cnn.ConnectionString = @"User Id=sim;Host=localhost;Database=sim;Character Set=UTF8;Persist Security Info=True;Schema=gsim;password=sim";
cnn.Charset = "UTF8";
cnn.Open();
CoreLab.PostgreSql.PgSqlCommand cmd = new CoreLab.PostgreSql.PgSqlCommand();
cmd.Connection = cnn;
cmd.CommandText = "INSERT INTO gsim.area_produttiva (nome) VALUES (:nome)";
CoreLab.PostgreSql.PgSqlParameter p = new CoreLab.PostgreSql.PgSqlParameter();
p.ParameterName = "nome";
p.Value = "provà"; // <-- The problem is about "à" char
p.PgSqlType = CoreLab.PostgreSql.PgSqlType.VarChar;
cmd.Parameters.Add(p);
cmd.ExecuteNonQuery();
cnn.Close();
}
Db creating script:
CREATE DATABASE sim
WITH OWNER = sim
ENCODING = 'UTF8';
Thanks.