
cdaorecordset::GetFieldValue --> variant
hi --
i'm trying to retrieve a string from a CDaoRecordSet using
GetFieldValue(), but am getting some strange return values.
Note: Most of this code is from Bob Place's GenericRecordSet
class on codeguru, i recommend it.
CString GenericRecordset::GetCString(CString ColumnName) {
COleVariant covFieldValue;
VARIANT *vFieldValue;
CString Holder;
GetFieldValue(ColumnName, covFieldValue);
vFieldValue = (LPVARIANT)covFieldValue;
Holder.Format("%s",vFieldValue->pbVal);
return Holder;
Quote:
}
for some fields, this works fine. for others (possibly those
with a Memo type), it only returns the first character of
the string. i can get the full string with:
Holder = vFieldValue->bstrVal;
but for the cases where the top code worked originally, that
returns garbage. i can't tell any difference in the two
VARIANTs that would allow me to differentiate betweent the
two cases, and documentationt that i can find suggests that
the value should always be in bstrVal if (vFieldValue.vt ==
VT_BSTR).
thanks for any suggestions
r