我试图通过调用存储过程来获取名称。
sql代码:
create procedure GetName
@ID int,
@name nvarchar(32) output
as
select @name=name from SalesInfo where ID=@ID
c代码
...
SQLRETURN rc;
SQLLEN cbParam = SQL_NTS;
int ID = 1;
wchar_t name[32];
rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &ID, 0, NULL);
rc = SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT_OUTPUT, SQL_C_WCHAR, SQL_WCHAR, SQL_DESC_LENGTH, 0, name, sizeof(name), &cbParam);
rc = SQLExecDirect(hstmt, TEXT("{call GetName(?,?)}"), SQL_NTS);
- 我收到了一个字符串,但有一条错误消息,“字符串数据,右截断”
- 字符串用空格填充,例如“name”