SQLPrepare error: [Microsoft][ODBC Microsoft Access Driver] Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.
-
Hi All, I am trying to write a prototype to insert values into a Ms-Access table by using ODBC driver and ACE database engine in VC++. software used: Ms-Access 2010(32 bit), ACE database engine(32 bit), Windows 8(64 bit), VC++ 2013 and the application is in 32 bit. code snippet: iRetCode = SQLAllocHandle(SQL_HANDLE_STMT, m_hdbc, &m_hstmt); if (iRetCode != SQL_SUCCESS && iRetCode != SQL_SUCCESS_WITH_INFO) return false; iRetCode = SQLPrepare(m_hstmt, (SQLCHAR*)&m_sSqlStatement, SQL_NTS); if ((iRetCode != SQL_SUCCESS && iRetCode != SQL_SUCCESS_WITH_INFO) || iRetCode != SQL_INVALID_HANDLE) { n = 1; CString strMsg; while ((retcode2 = SQLGetDiagRec(SQL_HANDLE_STMT, m_hstmt, n, SqlState, &NativeError, Msg, sizeof(Msg), &MsgLen)) != SQL_NO_DATA) { strMsg = Msg; AfxMessageBox(strMsg); n++; } SQLFreeHandle(SQL_HANDLE_STMT, m_hstmt); return false; } later I will bind the values to the m_sSqlStatement by using SQLBindParameter(m_hstmt,,,,,,,,,) I am using the database driver as "Driver={Microsoft Access Driver (*.mdb, *.accdb)}" input m_sSqlStatement = "INSERT INTO LaserExportTest VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" and the SQLPrepare error: "[Microsoft][ODBC Microsoft Access Driver] Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'." I tried to run the above Insert statement in Ms-Access 2010 database separately and it is able to insert values successfully. Please let me know the suggestions on insert statement that will be used in SQLPrepare statement. Thanks in advance, Chowdam.