gpt4 book ai didi

c++ - 未声明的标识符 SQL_SS_TABLE

转载 作者:太空宇宙 更新时间:2023-11-04 13:27:55 38 4
gpt4 key购买 nike

我想使用 ODBC 在 C++ 中使用表值参数。有许多用于使用 ODBC 处理 TVP 的有趣示例。例如here

一个很好的函数是SQLbinparameter .来自 here对于表值参数,此函数应如下所示:

r = SQLBindParameter(hstmt, 
2,// ParameterNumber
SQL_PARAM_INPUT,// InputOutputType
SQL_C_DEFAULT,// ValueType
SQL_SS_TABLE,// Parametertype
ITEM_ARRAY_SIZE,// ColumnSize: For a table-valued parameter this is the row array size.
0,// DecimalDigits: For a table-valued parameter this is always 0.
TVP,// ParameterValuePtr: For a table-valued parameter this is the type name of the
//table-valued parameter, and also a token returned by SQLParamData.
SQL_NTS,// BufferLength: For a table-valued parameter this is the length of the type name or SQL_NTS.
&cbTVP);// StrLen_or_IndPtr: For a table-valued parameter this is the number of rows actually use

但我收到错误:error C2065: SQL_SS_TABLE undeclared identifier

我应该怎么做才能解决这个问题?

最佳答案

它是一种特定于驱动程序的类型,需要安装相应驱动程序的 SDK 并包含 header 。它定义了 SQL_SS_TABLE 以及其他较新的 SQL Server 特定类型。

编辑 2022 年 11 月:

Microsoft 已开始弃用 ODBC Native Client 并建议切换到 Microsoft ODBC Driver for SQL Server .使用这些 SDK,包含目录现在更改为:

C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\VERSION\SDK\Include

VERSION 将被安装的驱动程序版本替换,当前最新版本是“Microsoft ODBC Driver 18 for SQL Server”的 180。此驱动程序的头文件是 msodbcsql.h

旧答案:

SQL Server 示例使用 Native Client 的 sqlncli.h 头文件位于

C:\Program Files\Microsoft SQL Server\110\SDK\Include

感谢“Viorel_”最初在 MSDN 论坛上回答了这个问题:Using new ODBC sql data typ SQL_SS_TABLE in c++

关于c++ - 未声明的标识符 SQL_SS_TABLE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32719721/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com