Page 1 of 1

PgSqlArray with PgSqlType.Text or VarChar

Posted: Mon 01 Aug 2011 14:09
by Ralf Jansen
Hi,

next Problem with PgSqlArray. When sending a Text or varchar Array to a stored function im getting a
invalid byte sequence for encoding 'UTF8'
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.


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();
    }
}
'fn_test' is just an empty stored function with a TEXT[] or VARCHAR[] parameter.


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.

Posted: Tue 02 Aug 2011 15:56
by Shalex
We have reproduced the "Offset and length were out of bounds..." error. We will investigate the issue and notify you about the results.

Posted: Wed 03 Aug 2011 10:48
by Shalex
The "Offset and length were out of bounds..." bug in the Unicode mode is fixed. We will post here when the corresponding build of dotConnect for PostgreSQL is available for download.

Posted: Fri 12 Aug 2011 13:43
by Shalex
New build of dotConnect for PostgreSQL 5.30.202 is available for download!
It can be downloaded from http://www.devart.com/dotconnect/postgr ... nload.html (trial version) or from Registered Users' Area (for users with valid subscription only): http://secure.devart.com/ .

For more information, please refer to http://www.devart.com/forums/viewtopic.php?t=21729 .