SQLite with C++

My latest article for Visual Studio Magazine is now online. This concludes the SQLite miniseries. I hope you’ve enjoyed it and do let me know if you’d like to learn more. SQLite is a fantastic little database engine. Here are links to all three articles.

1. Using SQLite with Modern C++

2. SQLite Performance and Prepared Statements

3. SQLite Queries and Primary Keys

I also covered SQLite in 10 Practical Techniques to Power Your Visual C++ Apps and I may do a course devoted to SQLite in the future.

5 thoughts on “SQLite with C++

  1. Jeff Barrett

    I am enjoying your Pluralsight video for using SQLite with C++ but I ran into a problem your struct sql_exception that after a search online looks like it has something with Update 3 for Visual Studio 2013. The code that is having a problem is this
    struct sql_exception
    {
    int code;
    string message;

    sql_exception(int result, char const *text) :
    code{result},
    message{text}
    {}
    };
    The error message is this
    C2797: ‘sql_exception::message’: list initialization inside member initializer list or non-static data member initializer is not implemented

    A fix from Microsoft about changes in Update 3 dealing with this error is here but I can’t figure out how to apply the fix to your code at the moment.
    http://msdn.microsoft.com/en-us/library/dn793970.aspx
    I appreciate your help with this!

    Reply
      1. Jeff Barrett

        Thanks for the quick response! That looks like it fixed my first problem but now I have a problem with the debug.h file and this struct
        struct Tracer
        {
        char const * m_filename;
        unsigned m_line;

        Tracer(char const * filename, unsigned const line) :
        m_filename{ filename },
        m_line{ line }
        {

        }

        template
        auto operator()(wchar_t const * format, Args… args) const -> void
        {
        wchar_t buffer[400];

        auto count = swprintf_s(buffer,
        L”%S(%d): “,
        m_filename,
        m_line);

        ASSERT(-1 != count);

        ASSERT(-1 != _snwprintf_s(buffer + count,
        _countof(buffer) – count,
        _countof(buffer) – count – 1,
        format,
        args…));

        OutputDebugString(buffer);
        }
        };
        #endif
        The error is this
        Error 1 error C2664: ‘void OutputDebugStringA(LPCSTR)’ : cannot convert argument 1 from ‘wchar_t [400]’ to ‘LPCSTR’
        Thanks again for your help!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s