This is my first post. I've just started using the Poco ODBC Data library to connect to SQL Server, and have hit a problem with the following code:
- Code: Select all
int id=-1;
Session session(m_sessionPool->get());
std::string query("SELECT CompanyId FROM Suppliers WHERE CompanyName=:name");
std::string customer("Example Company");
Statement statement = ( session << query, into(id), use(customer) );
statement.execute();
The execute() call fails with an exception giving an incorrect syntax near ":". I stepped into the code and found that the SQL code within the statement was:
- Code: Select all
"SELECT CompanyId FROM Suppliers WHERE CompanyName=:nameÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍýýýý««««««««îþîþ"
This corruption appears to happen in Poco/Data/StatementCreator.h in the function
- Code: Select all
template <typename T>
Statement operator << (const T& t)
/// Creates a Statement.
{
Statement stmt(_ptrImpl->createStatementImpl());
stmt << t;
return stmt;
}
Where the std::string that is passed in is "SELECT CompanyId FROM Suppliers WHERE CompanyName=:name" but the string stored in the stmt variable is corrupted as above.
If I use "SELECT CompanyId FROM Suppliers WHERE CompanyName=?" instead, I get two SQL errors: "The data types nvarchar and text are incompatible in the equal to operator"; and "Statement(s) could not be prepared".
Thanks in advance for any suggestions!





