The following code :generates error messages, which follow:
bool UACmUsers::GetUser(int userid) {
soci::session sql(dbU::Connection());
sql << "SELECT userid, username, password FROM uac_users WHERE userid = \":user\"",
soci::use(userid),
soci::into(iDuserid, indUserid),
soci::into(sDusername, indUsername), // This is line 61.
soci::into(sDpassword, indPassword);
return true;
}
dbU::Connection() is a function generating the connection string.
iDuserid, sDusername, and sDpassword are private members of UACmUsers, of types int and std::string.
indUserid, indUsername, andindPassword are private members of UACmUsers, of type soci::indicator.
There is a second, overloaded, function searching for the username. If I comment out this function so only the second one remains, the complier points to the same point in the second function.
bool UACmUsers::GetUser(const wxString& username);
I have tried removing two of the indicators, this does not solve the problem.
The errors:
E:\cpp\lib\soci\soci-4.0.0\include\soci/exchange-traits.h(41): error C2065: 'x_type': undeclared identifier
E:\cpp\lib\soci\soci-4.0.0\include\soci/bind-values.h(207): note: see reference to class template instantiation 'soci::details::exchange_traits<T>' being compiled
with
[
T=wxString
]
E:\cpp\lib\soci\soci-4.0.0\include\soci/bind-values.h(143): note: see reference to function template instantiation 'void soci::details::into_type_vector::exchange_<wxString,soci::indicator>(const soci::details::into_container<wxString,soci::indicator> &,...)' being compiled
E:\cpp\lib\soci\soci-4.0.0\include\soci/statement.h(50): note: see reference to function template instantiation 'void soci::details::into_type_vector::exchange<wxString,soci::indicator>(const soci::details::into_container<wxString,soci::indicator> &)' being compiled
E:\cpp\lib\soci\soci-4.0.0\include\soci/statement.h(199): note: see reference to function template instantiation 'void soci::details::statement_impl::exchange<wxString,soci::indicator>(const soci::details::into_container<wxString,soci::indicator> &)' being compiled
E:\cpp\lib\soci\soci-4.0.0\include\soci/ref-counted-statement.h(92): note: see reference to function template instantiation 'void soci::statement::exchange<wxString,soci::indicator>(const soci::details::into_container<wxString,soci::indicator> &)' being compiled
E:\cpp\lib\soci\soci-4.0.0\include\soci/once-temp-type.h(49): note: see reference to function template instantiation 'void soci::details::ref_counted_statement::exchange<const soci::details::into_container<wxString,soci::indicator>>(T &)' being compiled
with
[
T=const soci::details::into_container<wxString,soci::indicator>
]
E:\cpp\dev\Manager\src\UAC\models\UACmUsers.cpp(61): note: see reference to function template instantiation 'soci::details::once_temp_type &soci::details::once_temp_type::operator ,<wxString,soci::indicator>(const soci::details::into_container<wxString,soci::indicator> &)' being compiled
Can someone help me get SOCI to behave?
This is part of a project on GitHub. Links to the header and source files containing the above code.
Your strings aren't standard strings. wxString likely has no conversion support in SOCI.
Either do the conversions, or extend the type conversions. Perhaps not the most efficient but works:
Full Demo
Prints
Or on a subsequent run:
And the table contains
NOTES
In the sample there appears to be a memory leak when the insert statements throw. I guess this need to be reported upstream.
THINK TWICE before storing passwords in a database. Proper security rules of thumb: