c++ - SQLExecute always returning "[Microsoft][SQL Server Native Client 10.0]String data, right truncation" in parameters more than 8k sized -
when execute sqlexecute function returns me "[microsoft][sql server native client 10.0]string data, right truncation" when parameter has more 8k bytes. paste code below. i'm trying do: store xml file in column declared varbinary(max) through stored procedure via odbc drivers (visual c++ 2008) in sql server 2008 r2. sp converts varchar varbinary calling set @xml_file_bin = convert(varbinary(max), @xml_file)
works fine if try pasting whole xml int sql server management studio. think wrong binding in sqlbindparameter. code:
char* cxmlbuf; contains buffer retcode = sqlbindparameter( hstmt, //statementhandle 1, //parameternumber sql_param_input, //inputoutputtype sql_c_char, //valuetype sql_char, //parametertype sql_desc_length, //columnsize 0, //decimaldigits cxmlbuf, //parametervalueptr buflenght, //bufferlength &cbxml //strlen_or_indptr ); if (retcode != sql_success && retcode != sql_success_with_info) return; sword id = 0; sqlinteger cbid = 0; retcode = sqlbindparameter(hstmt, 2, sql_param_output, sql_c_sshort, sql_integer, 0, 0, &id, 0, &cbid); if (retcode != sql_success && retcode != sql_success_with_info) return; retcode = sqlprepare(hstmt, (sqlchar*)"{call my_store_proc(?, ?)}", sql_nts); if (retcode != sql_success && retcode != sql_success_with_info) return; retcode = sqlfreestmt(hstmt, sql_close); // clear cursor state retcode = sqlexecute(hstmt); //in part retcode -1 , "[microsoft][sql server native client //10.0]string data, right truncation" returned if xml buffer //has more 8k
found it! i've declared sqlinteger cbxml = sql_nts;
instead sqllen cbxml = 0;
thanks.
Comments
Post a Comment