我正在使用Visual Studio 2008和SQL Server,目前我有一個使用ADO的連接,但想要檢索表的列數...使用_bstr_t和ADO獲取C++中的列數
這裏是我
/*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);
它打印0
雖然有我的表 20列如何解決查詢或邏輯?
我看不到你正在執行該SQL;您似乎試圖將查詢本身轉換爲數字。這將是零。 –
@Roger Lipscombe:我如何補充說明,爲了用'Command.Execute()'執行'count',必須添加什麼指令? – cMinor