converting _variant_t to string
-
Hi there, I am using the ADO calls to connect to my database and have the following call: _variant_t varFieldValue; varFieldValue = m_pRecord->Fields->GetItem((long)nCol)->GetValue(); Now, at some point , I like to convert this varFieldValue to a string, preferably a STL string. Any tips on how to do this? thanks
-
Hi there, I am using the ADO calls to connect to my database and have the following call: _variant_t varFieldValue; varFieldValue = m_pRecord->Fields->GetItem((long)nCol)->GetValue(); Now, at some point , I like to convert this varFieldValue to a string, preferably a STL string. Any tips on how to do this? thanks
this should get your variant value into a CString. CString strTest; strTest = varFieldValue.bstrVal;
-
this should get your variant value into a CString. CString strTest; strTest = varFieldValue.bstrVal;
Nope, that won't work if the variant isn't already a VT_BSTR. However using static_cast <_bstr_t> (v) will convert the variant to a BSTR and return the string. Tim Smith I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?