--- sqlite3x_command.cpp.prep 2007-12-24 15:43:58.000000000 +0100 +++ sqlite3x_command.cpp 2007-12-24 15:47:31.000000000 +0100 @@ -47,9 +47,18 @@ #if SQLITE3X_USE_WCHAR sqlite3_command::sqlite3_command(sqlite3_connection &con, const std::wstring &sql) : con(con),stmt(0),refs(0),argc(0) { const void *tail=NULL; - if(sqlite3_prepare16(con.db(), sql.data(), (int)sql.length()*2, &this->stmt, &tail)!=SQLITE_OK) - throw database_error(con); - + int rc = +#if (SQLITE_VERSION_NUMBER >= 3003009) + sqlite3_prepare16_v2 +#else + sqlite3_prepare16 +#endif + (con.db(), sql.data(), (int)sql.length()*2, &this->stmt, &tail); + if( SQLITE_OK != rc ) + { + throw database_error("sqlite3_command::prepare failed. Reason=[%s]", + sqlite3_errmsg( this->con.db() ) ); + } this->argc=sqlite3_column_count(this->stmt); } #endif @@ -58,7 +67,13 @@ { if( this->stmt ) this->finalize(); const char *tail=NULL; - int rc = sqlite3_prepare( this->con.db(), sql, len, &(this->stmt), &tail ); + int rc = +#if (SQLITE_VERSION_NUMBER >= 3003009) + sqlite3_prepare_v2 +#else + sqlite3_prepare +#endif + ( this->con.db(), sql, len, &(this->stmt), &tail ); if( SQLITE_OK != rc ) { throw database_error("sqlite3_command::prepare([%s]) failed. Reason=[%s]",