title: C++ SQLExecDirect INSERT doesn't work
body: <p>I've wrote a simple SQL C++ Wrapper-Class, where I encountered a real strange Problem. When I call an INSERT-Command with SQLExecDirect, the data does not appear in the SQL Database (SQL Server 2012), although SQLRowCount returns one row. The table, which I'm trying to write to, is named "Person" and has four columns (ID (AUTOINCREMENT), Firstname (nvarchar(100)), Lastname (nvarchar(100)), Birthday (date))</p>
  
  <p>Here is my code:</p>
  
  <p>Class-Constructor (EnvHandle, DBCHandle and StmtHandle are class-members)</p>
  
  <pre><code>    SQLDatabase::SQLDatabase()
  {
      SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &amp;EnvHandle);
  
      SQLSetEnvAttr(EnvHandle, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)SQL_OV_ODBC3, 0);
  
      SQLAllocHandle(SQL_HANDLE_DBC, EnvHandle, &amp;DBCHandle);
  
      SQLSetConnectAttr(DBCHandle, SQL_ATTR_AUTOCOMMIT, (SQLPOINTER)SQL_AUTOCOMMIT_OFF, SQL_IS_INTEGER);
  }
  </code></pre>
  
  <p>Query-Member-Function</p>
  
  <pre><code>    int SQLDatabase::ExecuteNonQuery(std::wstring Command)
  {
      SQLRETURN RetCode = -1;
      SQLINTEGER RowCount = 0;
  
      SQLAllocHandle(SQL_HANDLE_STMT, DBCHandle, &amp;StmtHandle);
  
      RetCode = SQLExecDirect(StmtHandle, (SQLWCHAR*)Command.c_str(), Command.length());
      if (RetCode == SQL_SUCCESS || RetCode == SQL_SUCCESS_WITH_INFO)
      {
          SQLRowCount(StmtHandle, &amp;RowCount);
          SQLFreeHandle(SQL_HANDLE_STMT, StmtHandle);
          return RowCount;
      }
      else
      {
          SQLFreeHandle(SQL_HANDLE_STMT, StmtHandle);
          return -1;
      }
  
  }
  </code></pre>
  
  <p>Function-Call in main.cpp</p>
  
  <pre><code>        wcout &lt;&lt; "Firstname:\n&gt;";
      wcin &gt;&gt; Firstname;
      wcout &lt;&lt; "Lastname:\n&gt;";
      wcin &gt;&gt; Lastname;
      wcout &lt;&lt; "Birthday:\n&gt;";
      wcin &gt;&gt; Birthday;
  
      InsRows = database.ExecuteNonQuery(L"INSERT INTO Person (Firstname,Lastname,Birthday) VALUES ('" + Firstname + L"','" + Lastname + L"','" + Birthday + L"')");
      if (InsRows == -1)
          database.Error();
      else
          std::wcout &lt;&lt; InsRows &lt;&lt; " rows affected!" &lt;&lt; std::endl;
  </code></pre>
  
  <p>As already said, "database.ExecuteNonQuery" returns one row.</p>
  
  <p>When take a look at the table in SQL Management Studio, the datarow hasn't been added. I've already traced the queries on the table. The query appears in the tracelog correctly without any additional info. My IDE is Visual Studio 2013.</p>
  
  <p>Any ideas how I could get the data into the table?</p>
  
  <p>Thanks!</p>
  
  <p>Sebastian</p>