next Problem with PgSqlArray. When sending a Text or varchar Array to a stored function im getting a
Exception when the Text contains German Umlauts or any other character with diacritics. I've tried adding a "SET CLIENT_ENCODING TO 'utf8'" (server encoding is utf8) to the command but that did not change anything.invalid byte sequence for encoding 'UTF8'
Testcode
Code: Select all
object[] array = { "Hello", "World", "böse" };
using (PgSqlConnection con = new PgSqlConnection("aValidConnectionString"))
{
con.Open();
using (PgSqlTransaction tx = con.BeginTransaction())
{
using (PgSqlCommand command = new PgSqlCommand(@"fn_test", con))
{
command.CommandText = @"fn_test";
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@cterms", PgSqlType.Array).Value =
new PgSqlArray(array, PgSqlType.Text, 1, array.Length);
command.ExecuteNonQuery();
}
tx.Commit();
}
}
Ralf
Edit: Adding 'Unicode=true' to the connection string helped somewhat. I get a different Exception now

Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.