wstring to SQLString

Hi everyone! Today’s post will be really short. It’s for those who is looking for this solution in C++ programming.

I have tried to search for this solution online but it wasn’t available. Hence, by using different resources and trail & error, I came up with this solution.

Below is an example of how to convert a wstring variable to an SQLString:

std::wstring wstr = L”hello”;

std::string str;

sql::SQLString sqlStr;

str = std::string(wstr.begin(), wstr.end());

sqlStr = str;

Initially we have a wstring and we cast it to a string type. Then finally, we uses c_str() to obtain an sql::SQLString.

Hope this will be helpful for those who stumble across this blog while finding for solutions. You may also send me some tips if you like my work and want to see more of such content. Funds will mostly be used for my boba milk tea addiction. The link is here. 🙂

Leave a Reply

Please log in using one of these methods to post your comment:

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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.