SQLExecute 始终以超过 8k 大小的参数返回"[Microsoft][SQL Server Native Client 10.0]String data, right truncation"
SQLExecute always returning "[Microsoft][SQL Server Native Client 10.0]String data, right truncation" in parameters more than 8k sized
当我执行SQLExecute函数时,当我的参数超过8k字节时,它总是返回"[Microsoft][SQL Server Native Client 10.0]字符串数据,右截断"。我将粘贴下面的代码。我正在尝试做的是:通过 SQL Server 2008 R2 中的 ODBC 驱动程序 (Visual C++ 2008) 通过存储过程将 XML 文件存储在声明为 varbinary(max) 的列中。SP 从 varchar 转换为 varbinary 调用SET @XML_FILE_BIN = CONVERT(VARBINARY(MAX), @XML_FILE)
如果我尝试将整个 XML 粘贴到 SQL Server Management Studio 中,它可以正常工作。我认为SQLBindParameter中的绑定有问题。代码:
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
找到了!我声明SQLINTEGER cbXml = SQL_NTS;
而不是SQLLEN cbXml = 0;
谢谢。
相关文章:
- 为什么导入Mixed native/CLR lib.dll的本机C++应用程序没有在Mixed lib.dll中的外部变
- Android Java USB for native cpp
- React Native (Android):无法通过 JNI 在 jobject 中返回字符串
- FindPOCO CMAKE 脚本无法找到 MYSQL::client
- boost beast Websocket Multi Request Server/Client 并不是真正的 mul
- OpenCV Native Android cvtColor crash
- CMake Dlibdotnet.native生成错误
- 如何使用Java Native Interface在C++中导入python库-Android Studio
- Android Studio External Native Build 预编译标头
- 为什么march=native会破坏我的程序?
- React-Native android NDK
- 在 C++/CLI/C# 项目中启用"Native Code Debugging"导致应用程序崩溃
- 我可以将 RetroArch 移植到 Native Client 吗?
- regsvr32 会导致 CDatabase destrucor 在使用 SQL Native Client (v200
- 如何在C++内部的Google Native Client中获取数组中的值的总和
- Native Client模块是否可以呈现由C++代码生成的HTML
- 何时可以安全地以编程方式卸载SQL Server Native Client
- 适用于C的BlueZ蓝牙库是Google的Native-Client SDK的白名单API之一吗?
- Google Native Client Visual Studio外接程序:Webserver无法启动,因为httpd
- SQLExecute 始终以超过 8k 大小的参数返回"[Microsoft][SQL Server Native Client 10.0]String data, right truncation"