Hello all,
im writing a c++ program to interact with an SQLServer database.
my code will run a query and retrieve data fine.
for example SELECT data FROM TestTable returns all strings
from the data column.
but when i run the following statement
INSERT INTO TestTable (data) VALUES ('HELP')
i get the following error:
37000:1:170:[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect
syntax near ' '.
37000:2:8180::[Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not be prepared.
The allocate and prepare functions return success so im not
sure whats going on.
any help would be great.
using visual c++ with ODBC connection to SQL server 2003
// Allocate memory for the statement handle
retcode = SQLAllocHandle(SQL_HANDLE_STMT,hDBC,&hStmt);
if(retcode == SQL_SUCCESS)
printf("\nAlloc Handle: SQL_SUCCESS");
// Prepare the SQL statement by assigning it to the statement handle
retcode = SQLPrepare (hStmt, szSqlStr, sizeof (szSqlStr));
if(retcode == SQL_SUCCESS)
printf("\nPrepare: SQL_SUCCESS");
// Execute the SQL statement handle
printf("\nSending statement: %s",szSqlStr);
retcode = SQLExecute (hStmt);
if(retcode == SQL_ERROR)
{
printf("\nStatement: SQL_ERROR\n");
ExtractError(hStmt, SQL_HANDLE_STMT);
}