Insert Unicode string

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

This has probably been addressed before, but I couldn't find it in the
archives.

I try to store unicode data with ado.net. I'm using VS2005 and C++.
In order to find Unicode data I have copied some text from www.unicode.org

I have taken out the most important parts from my code in order to show what
I try to do. I have a __wchar_t string that I try to run with SqlCommand.
__wchar_t SQLStr[20000];
wcscpy(SQLStr,L"INSERT INTO ccc (ccc_id,data) VALUES (12690,'Czech -
PoÄítaÄe, ze své podstaty, pracují pouze s Äísly Greek - Οι ηλεκτÏονικοί')");
....
m_SQLSCommand = new System::Data::SqlClient::SqlCommand(SQLStr, Conn);
....
It is finally executed with ExecuteNonQuery()

The problem is that when I look in the database and try to read it it looks
like this
"Czech - Pocítace, ze své podstaty, pracují pouze s císly Greek - ??
??e?t???????"

If I insert the same data with SQL Enterprise Manager, I can read it with
ADO.NET. But I can't insert it correct from my program.
When I run the program in debug-mode, the text looks fine all the way.
The datatype that I'm inserting to is NVARCHAR
What could be the problem?

Thorsten
 
Hi,

Use parametrised insert instead of puting values into sqlcommand text.
 
Back
Top