diff options
Diffstat (limited to 'libodbcpp/odbc-command.cpp')
-rw-r--r-- | libodbcpp/odbc-command.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/libodbcpp/odbc-command.cpp b/libodbcpp/odbc-command.cpp index d96234d..43572c8 100644 --- a/libodbcpp/odbc-command.cpp +++ b/libodbcpp/odbc-command.cpp @@ -9,23 +9,23 @@ ODBC::Command::Command(const Connection & c, const std::string & s) : { RETCODE rc = SQLAllocHandle(SQL_HANDLE_STMT, c.conn, &hStmt); if (!SQL_SUCCEEDED(rc)) { - throw Error(rc, SQL_HANDLE_STMT, hStmt, "Allocate statement handle"); + throw Error(rc, SQL_HANDLE_STMT, hStmt); } rc = SQLSetStmtAttr(hStmt, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER)SQL_CURSOR_DYNAMIC, 0); if (!SQL_SUCCEEDED(rc)) { - throw ConnectionError(rc, SQL_HANDLE_STMT, hStmt, "Set scrollable cursor"); + throw ConnectionError(rc, SQL_HANDLE_STMT, hStmt); + } + rc = SQLPrepare(hStmt, (SQLCHAR*)sql.c_str(), sql.length()); + if (!SQL_SUCCEEDED(rc)) { + SQLFreeHandle(SQL_HANDLE_STMT, hStmt); + throw Error(rc, SQL_HANDLE_STMT, hStmt); } - rc = SQLPrepare(hStmt, (SQLCHAR*)sql.c_str(), sql.length()); - if (!SQL_SUCCEEDED(rc)) { - SQLFreeHandle(SQL_HANDLE_STMT, hStmt); - throw Error(rc, SQL_HANDLE_STMT, hStmt, "Prepare statement"); - } SQLSMALLINT pcount; - rc = SQLNumParams(hStmt, &pcount); - if (!SQL_SUCCEEDED(rc)) { - SQLFreeHandle(SQL_HANDLE_STMT, hStmt); - throw Error(rc, SQL_HANDLE_STMT, hStmt, "Parameter count"); - } + rc = SQLNumParams(hStmt, &pcount); + if (!SQL_SUCCEEDED(rc)) { + SQLFreeHandle(SQL_HANDLE_STMT, hStmt); + throw Error(rc, SQL_HANDLE_STMT, hStmt); + } params.resize(pcount); } |