Search code examples
sql-serverormactiverecordcastle-activerecord

Storing unicode strings to SQL Server via ActiveRecord


I am using Castle ActiveRecord as my ORM. When I try to store unicode strings, I get question marks instead.

Saving unicode strings worked perfectly when I was using mysql, but when I recently switch to SQL Server it broke. How should I go about fixing this?


Solution

  • You're most likely using the incorrect SQL Server data type. varchar is meant for a plain-old character while nvarchar is meant for Unicode characters. The same applies for char & nchar and text and ntext.

    MSDN for SQL Server data type
    MSDN for SQL Server Unicode data