我正在使用 Visual Studio 2008 和 SQL Server,目前我有一个使用 ADO 的连接,但想检索一个表的列数......
这是我所拥有的
/*CODE FOR connecting to database**/
/*query to know number of columns in table*/
_bstr_t sSQLd="Select Count(*) From INFORMATION_SCHEMA.COLUMNS Where TABLE_NAME='[dbo].[mytable]';";
/*define variable to hold number of columns and
print number of coulms as an integer
*/
int COLS_PER_ROW = wcstod(sSQLd, NULL);
printf("COLS_PER_ROW: %d", COLS_PER_ROW);
尽管我的表中有 20 列,但它会打印0
如何修复查询或逻辑?