diff -r a871779a4e3c -r b4af13653313 src/Connection.cpp --- a/src/Connection.cpp Mon Jun 01 00:14:40 2020 +0200 +++ b/src/Connection.cpp Mon Jun 01 17:14:22 2020 +0200 @@ -41,10 +41,7 @@ PreparedStatement* Connection::prepareStatement(relpipe::reader::string_t sql) { SQLHSTMT statement = OdbcCommon::allocateHandle(SQL_HANDLE_STMT, connection); SQLRETURN result = SQLPrepare(statement, (SQLCHAR*) convertor.to_bytes(sql).c_str(), SQL_NTS); - if (OdbcCommon::isNotSuccessful(result)) { - OdbcCommon::freeHandle(SQL_HANDLE_STMT, statement); - throw SqlException(L"Unable to prepare statement", result, SQL_HANDLE_DBC, connection); // TODO: SQL_HANDLE_STMT? - } + if (OdbcCommon::isNotSuccessful(result)) throw SqlException(L"Unable to prepare statement", result, SQL_HANDLE_STMT, statement, true); return new PreparedStatement(statement); }