[ruby-dbi-users] wrong results data from queries

rob fury123 at gmail.com
Sun Feb 1 19:37:04 EST 2009


using dbi i am getting wrong data when i try to query a database, i
try to explain with an example:
In a table of  the database i have a column with data type
nvarchar(10), let's say that in a field i have a string like
0000000070, when i query the database for the data in that column, dbi
returns me 000000007\000\000 (this is the result from row.inspect)

If i strip the string in the row['data']  i get a string length 9 (but
the data in the database is 10 length!)

It is just an example, this problem happen to a lot of query that i
execute on this database, it always replaces the last character of the
data retrieved from the database with these \000\000, the real
retrieved data is always missing the last character.

The database that i use is MS SQL 2000 and to connect to it i use an
ODBC driver.
I was thinking that there was some problems in the odbc at first, but
i tested same query, same database, same odbc driver using perl and
dbi for perl and i get corrects results.

So i suppose is a dbi problem, but i don't know where to look for to resolve it.

Someone else has seen a similar problem ?

Bye thanks for the help.

More information about the ruby-dbi-users mailing list