Prorblem assigning _variant_t to _bstr when _variant_t is an integer
- From: kjnilsson@xxxxxxxxx
- Date: 15 Jan 2007 01:26:32 -0800
Hi,
I have a problem with a simple sql program I alm writing. The code
below fails on the line else b = tvar.bstrVal when the variant contains
an integer (i.e. it has collected an integer from a query). It works
fine when it contains any other sql type.
code:
while(!pRecset->EndOfFile){
for(long l = 0; l < c; l++){
tvar = pRecset->Fields->GetItem(l)->Value;
if(tvar.vt == VT_NULL) b = "";
else b = tvar.bstrVal;
std::cout << b;
}
It fails in this function:
inline _bstr_t::Data_t::Data_t(const wchar_t* s)
: m_str(NULL), m_RefCount(1)
{
m_wstr = ::SysAllocString(s); // <--- it fails here
if (m_wstr == NULL && s != NULL) {
_com_issue_error(E_OUTOFMEMORY);
}
}
Somehow it seems like it is unable to assign the variant to the bstr
when the variant is an integer. I am sure I have written code that has
worked with integer in the past.
Can anyone help?
Please let me know if this is not the appropriate forum to post this.
Thanks and regards
Karl Nilsson
.
- Follow-Ups:
- Re: Prorblem assigning _variant_t to _bstr when _variant_t is an integer
- From: Stephen Howe
- Re: Prorblem assigning _variant_t to _bstr when _variant_t is an integer
- From: Bob Barrows [MVP]
- Re: Prorblem assigning _variant_t to _bstr when _variant_t is an integer
- Prev by Date: Re: OleDbConnectionString Vista
- Next by Date: Re: Prorblem assigning _variant_t to _bstr when _variant_t is an integer
- Previous by thread: Re: OleDbConnectionString Vista
- Next by thread: Re: Prorblem assigning _variant_t to _bstr when _variant_t is an integer
- Index(es):
Relevant Pages
|