on 2015 Feb 05 5:59 PM
I am trying to update a Sybase table via Microsofts ODBC API. The following is the basics of the C++ I am trying to execute. In table, TableNameXXX, ColumnNameXXX has a type of NVARCHAR( 200 ).
SQLWCHAR updateStatement[ 1024 ] = L"UPDATE TableNameXXX SET ColumnNameXXX = N'Executive Chair эюя' WHERE PKEYXXX = 'VALUE'";
if( ret = SQLExecDirect( hstmt, ( SQLWCHAR* ) updateStatement, SQL_NTS ) != SQL_SUCCESS )
{
// Handle Error
}
The Sybase database has a CatalogCollation of 1252LATIN1, CharSet of windows-1252, Collation of 1252LATIN1, NcharCharSet of UTF-8 and an NcharCollation of UCA.
Once this works for the Sybase ODBC connection I need to get it to work in various other ODBC drivers for other databases.
I do not get any errors however - the data in the database is not the unicode I attempted to update.
Does anyone know how to get this to work? What am I missing?
Request clarification before answering.
Hi David,
SQL statements are always parsed in the character set of the database (so Windows-1252 in this case). If you wish to pass Unicode/NCHAR data, you need to do one of the following (from: http://dcx.sap.com/index.html#sa160/en/dbadmin/natlang-s-5322854.html )
So for ODBC, you will want to use prepared execution with SQLPrepare, SQLBindParameter, and SQLExecute.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Got it working with SELECT UNISTR...
SQLWCHAR updateStatement[ 1024 ] = L"UPDATE TableNameXXX SET ColumnNameXXX = ( SELECT UNISTR( 'Executive Chair \\u044F\\u044D\\u044E\\u044F' ) ) WHERE PKEYXXX = 'VALUE'";
Thanks for your help.
User | Count |
---|---|
52 | |
6 | |
5 | |
5 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.