0
當我執行SQLExecute函數時,它始終返回「Microsoft [SQL Server Native Client 10.0]字符串數據,正確的截斷「當我的參數超過8k字節。我將粘貼下面的代碼。 我在做什麼:在SQL Server 2008 R2中通過ODBC驅動程序(Visual C++ 2008)通過存儲過程將XML文件存儲在聲明爲varbinary(max)的列中。 SP從varchar轉換爲varbinary調用SET @XML_FILE_BIN = CONVERT(VARBINARY(MAX), @XML_FILE)
如果我嘗試在SQL Server Management Studio中粘貼整個XML,它會正常工作。 我認爲SQLBindParameter中的綁定有問題。 該代碼:SQLExecute總是返回「[Microsoft] [SQL Server Native Client 10.0]字符串數據,右截斷」參數大於8k大小
char* cXmlBuf; it contains my 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 any cursor state
retcode = SQLExecute(hstmt);
//in this part retcode is -1 and "[Microsoft][SQL Server Native Client
//10.0]String data, right truncation" is returned if my XML buffer
//has more than 8k