oledb32: Support VT_NULL when converting to DBTYPE_BSTR.

This commit is contained in:
Alistair Leslie-Hughes 2013-05-17 12:21:12 +10:00 committed by Alexandre Julliard
parent c8d4b1cc5e
commit d3c3a38f69
2 changed files with 20 additions and 3 deletions

View File

@ -534,9 +534,18 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface,
}
break;
case DBTYPE_VARIANT:
VariantInit(&tmp);
if ((hr = VariantChangeType(&tmp, (VARIANT*)src, 0, VT_BSTR)) == S_OK)
*d = V_BSTR(&tmp);
if(V_VT((VARIANT*)src) == VT_NULL)
{
*dst_status = DBSTATUS_S_ISNULL;
*dst_len = get_length(DBTYPE_BSTR);
return S_OK;
}
else
{
VariantInit(&tmp);
if ((hr = VariantChangeType(&tmp, (VARIANT*)src, 0, VT_BSTR)) == S_OK)
*d = V_BSTR(&tmp);
}
break;
default: FIXME("Unimplemented conversion %04x -> BSTR\n", src_type); return E_NOTIMPL;
}

View File

@ -977,6 +977,14 @@ static void test_converttobstr(void)
ok(!lstrcmpW(b, dst), "got %s\n", wine_dbgstr_w(dst));
SysFreeString(dst);
SysFreeString(b);
V_VT(&v) = VT_NULL;
dst = (void*)0x1234;
hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_BSTR, 0, &dst_len, &v, &dst, sizeof(dst), 0, &dst_status, 0, 0, 0);
ok(hr == S_OK, "got %08x\n", hr);
ok(dst_status == DBSTATUS_S_ISNULL, "got %08x\n", dst_status);
ok(dst_len == sizeof(BSTR), "got %ld\n", dst_len);
ok(dst == (void*)0x1234, "got %p\n", dst);
}
static void test_converttowstr(void)