Writing SQL queries for SQLite with MFC primitives
I am using SQLite to store the state of my program. sqlite3_exec () takes the SQL query as a string. So I have a lot of code that builds queries like this, combining multiple instances CString
and feeling like I'm doing something wrong.
Is there a better way to do this while staying within the primitives provided in SQLite and MFC?
a source to share
This nifty piece of code provides a nice C ++ wrapper around SQLite3. It has very good binding methods, which saves a lot of unnecessary lines from your code (CStrings in this case). Check it; there are also many examples.
a source to share
I don't think there is a way to leverage MFC's capabilities to more easily access the SQLite API.
Due to the fact that the SQLite interface is C-oriented , it would be better to encapsulate access with a C ++ wrapper class, and you can use normal character arrays and sprintf to fill dynamic values inside that class (although you can continue with CStrings ... if you find them clearer). In the meantime, there is no need to worry about it. ”
We, at work, have a class that encapsulates access and allows us not to create an explicit sql statement.
The example mentioned by nhaa123 deserves a +1 vote!
a source to share