我有一個查詢應該請求使用Qt框架實際向SQL數據庫發出請求的前X個記錄。我已經驗證了當我放置一個硬編碼的數字查詢是成功的,但是當我嘗試綁定到它時,我得到一個錯誤。Qt查詢頂部號碼記錄選擇
query.prepare("SELECT TOP :numberToSelect"
" deviceId"
" , latitude"
" , longitude"
" , [timeStamp]"
" FROM Positions "
" WHERE [address] = ''"
" ORDER BY [timeStamp] DESC");
query.bindValue(":numberToSelect", numberMissing);
變量numberMissing是在傳遞一個無符號短的運行後我收到此錯誤:
Unable to execute statement: "[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near '@P1'. [Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not be prepared. QODBC3: Unable to execute statement" "SELECT TOP ? deviceId , latitude , longitude , [timeStamp] FROM Positions WHERE [address] = '' ORDER BY [timeStamp] DESC"
我看不出錯誤是什麼。
我使用Qt,它支持Oracle風格的參數。 – JadziaMD 2012-01-13 17:59:47