I’m attempting to insert into a column and I’m only seeing the first character of the string I’m inserting. I’ve been bashing my head into this problem for a little while now.
in my program Unicode is defined. I’m using ODBC and Sybase SQLAnywhere. The program runs without compiler error, and the column I’m trying to insert into takes a varchar. I’m using SQLBindParameter from odbc32.lib on windows server 2003 (WARNING:: legacy code incoming).
Verify is just an assert I defined. EFields is a std::map where TSTRING is defined as
typedef std::basic_string<TCHAR> TSTRING;
Here’s my ODBC Code.
bufSize = sizeof(TCHAR) * (EFields.find(_T("clientipaddress"))->second.length()); //not null terminated
VERIFY(::SQLBindParameter(hstmt, 3, SQL_PARAM_INPUT, SQL_C_TCHAR, SQL_VARCHAR, EFields.find(_T("clientipaddress"))->second.length() , 0 ,
(SQLPOINTER)EFields.find(_T("clientipaddress"))->second.c_str(), bufSize, NULL) == SQL_SUCCESS);
The string that’s being passed in is an IP (this one starts with 10.1). I’ve been asked to use a varchar so that the code doesn’t break when IPV6 becomes more common use. Thank you in advanced.
Changing from from Varchar to Nvarchar in the database solved my problem.