PgSqlArray with PgSqlType.Text or VarChar

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
Ralf Jansen
Posts: 3
Joined: Fri 29 Jul 2011 15:12

PgSqlArray with PgSqlType.Text or VarChar

Post by Ralf Jansen » Mon 01 Aug 2011 14:09

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.

Shalex
Site Admin
Posts: 8245
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Tue 02 Aug 2011 15:56

We have reproduced the "Offset and length were out of bounds..." error. We will investigate the issue and notify you about the results.

Shalex
Site Admin
Posts: 8245
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Wed 03 Aug 2011 10:48

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.

Shalex
Site Admin
Posts: 8245
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Fri 12 Aug 2011 13:43

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 .

Post Reply