标签:
http://bbs.csdn.net/topics/390601634
CString CMyDB::VariantToString(
const
_variant_t &var)
{
CString strValue;
switch
(var.vt)
{
case
VT_BSTR:
//字符串
case
VT_LPSTR:
//字符串
case
VT_LPWSTR:
//字符串
strValue = (
LPCTSTR
)(_bstr_t)var;
break
;
case
VT_I1:
case
VT_UI1:
strValue.Format(
"%d"
, var.bVal);
break
;
case
VT_I2:
//短整型
strValue.Format(
"%d"
, var.iVal);
break
;
case
VT_UI2:
//无符号短整型
strValue.Format(
"%d"
, var.uiVal);
break
;
case
VT_INT:
//整型
strValue.Format(
"%d"
, var.intVal);
break
;
case
VT_I4:
//整型
strValue.Format(
"%d"
, var.lVal);
break
;
case
VT_I8:
//长整型
strValue.Format(
"%d"
, var.lVal);
break
;
case
VT_UINT:
//无符号整型
strValue.Format(
"%d"
, var.uintVal);
break
;
case
VT_UI4:
//无符号整型
strValue.Format(
"%d"
, var.ulVal);
break
;
case
VT_UI8:
//无符号长整型
strValue.Format(
"%d"
, var.ulVal);
break
;
case
VT_VOID:
strValue.Format(
"%8x"
, var.byref);
break
;
case
VT_R4:
//浮点型
strValue.Format(
"%.4f"
, var.fltVal);
break
;
case
VT_R8:
//双精度型
strValue.Format(
"%.8f"
, var.dblVal);
break
;
case
VT_DECIMAL:
//小数
strValue.Format(
"%.8f"
, (
double
)var);
break
;
case
VT_CY:
{
COleCurrency cy = var.cyVal;
strValue = cy.Format();
}
break
;
case
VT_BLOB:
case
VT_BLOB_OBJECT:
case
0x2011:
strValue =
"[BLOB]"
;
break
;
case
VT_BOOL:
//布尔型
strValue = var.boolVal ?
"TRUE"
:
"FALSE"
;
break
;
case
VT_DATE:
//日期型
{
DATE dt = var.date;
COleDateTime da = COleDateTime(dt);
strValue = da.Format(
"%Y-%m-%d %H:%M:%S"
);
}
break
;
case
VT_NULL:
//NULL值
strValue =
""
;
break
;
case
VT_EMPTY:
//空
strValue =
""
;
break
;
case
VT_UNKNOWN:
//未知类型
default
:
strValue =
"UN_KNOW"
;
break
;
}
return
strValue;
}
CString xinghao;
//access 表字段
CString lujing;
//access表字段
xinghao=VariantToString(m_pRecordset->GetCollect(
"xinghao"
));
//获取字段存在xinghao变量中
lujing=VariantToString(m_pRecordset->GetCollect(
"lujing"
));
//获取字段存在xinghao变量中
//直接显示 不用m_Edit 了
GetDlgItem(IDC_EDIT3)->SetWindowText(xinghao);
标签:
原文地址:http://www.cnblogs.com/sankye/p/4499670.html