[Mono-list] Odbc.DataReader.GetValue returns wrong data on CHAR columns

lunkwill@gmx.net lunkwill@gmx.net
Thu, 28 Apr 2005 11:07:42 +0200 (MEST)


Mono Hackers!

I've come over a problem with System.Data.Odbc. I know: why the hack use
ODBC?
My production system is Informix. And I found no (affordable) Informix
driver so far. If anybody has a hint in this direction, let me know!

My problem is, that GetValue() always returns the length 255 for CHAR fields
when using ODBC. 
This is because a NULL-character is returned at the end of the string (which
in my opinion is the actual bug). This leads to the wrong string size and to
a complete mess when I try to display a database result in a ASP.NET
DataGrid.

If I remove the NULL manually, everything is OK.
I tested this with Mono 1.1.6 (on Windows and SLES9/unixODBC); MS .NET
behaves OK - no NULL characters and string length is correct.

This is no Informix specific behaviour. It appears everytime on every CHAR
column when using ODBC. VARCHARS work OK.
I have created a test case for the Firebird database in Bugzilla
(http://bugzilla.ximian.com/show_bug.cgi?id=74758) for easier reproduction.

/daniel

-- 
+++ GMX - die erste Adresse für Mail, Message, More +++

10 GB Mailbox, 100 FreeSMS  http://www.gmx.net/de/go/topmail