Ali Kazmi
Ali Kazmi

Reputation: 3660

Strings are appended with special characters when returned from the database

I am using NHibernate to query an Oracle 8i database. The problem is that all the strings in the returned objects are postfixed with special characters. For e.g.

CUSTOMER,ONE�������

The nhibernate field type is AnsiString and the Oracle datatype is CHAR(20) and the Character set is CHAR_CS. I am totally new with Oracle so i don't have a clue whats going on :(

Upvotes: 2

Views: 404

Answers (2)

Mac
Mac

Reputation: 8339

CHAR(20) means the field is padded as necessary to be exactly 20 characters long. The padding character is a blank.

There must be a problem somewhere in your character set settings if padding characters appear as question marks. You may find more insight on your problem here.

What you need here is to trim the returned strings, or better yet move to VARCHAR2(20).

Upvotes: 4

Ali Kazmi
Ali Kazmi

Reputation: 3660

I couldn't find a proper solution for this issue but changing the nhibernate driver from 'OracleClientDriver' to 'OleDbDriver' solved this issue. Still if anyone knows how to tackle this issue properly please let me know as I don't like using the OldDbDriver for accessing Oracle because of possible compatibility issues.

Upvotes: 0

Related Questions