_RecordsetPtr mpRecordset;
temp = (LPCTSTR)(_bstr_t)mpRecordset->GetCollect( "FLAG");如果不是空值,程序正常运行.否则出现Run Time错误!

解决方案 »

  1.   

    _RecordsetPtr mpRecordset;
    if (mpRecordset->GetCollect( "FLAG") != NULL)
        temp = (LPCTSTR)(_bstr_t)mpRecordset->GetCollect( "FLAG");   //you can not convert null to any type, so you should check it first.
      

  2.   

    D:\C学习3\testNULL\testNULLDlg.cpp(185) : error C2666: '!=' : 9 overloads have similar conversions
    Error executing cl.exe.
    报错了!其实我也知道要先判断一下,关键是我不知道怎么判断?
    还有如果是空串就又是对的!难道空串和空值在数据库中不同吗?
      

  3.   

    _variant data;
    data = mpRecordset->GetCollect( "FLAG");
    if (data.vtxxx != VT_NULL)  //i forget data.vtxxx, you can check it in vc, it will auto display when you write [data.], so do it yourself.
      

  4.   

    自己解决:改为:if (mpRecordset->GetCollect( "FLAG").vt != NULL)
    没人回答正确,我不想给分了怎么办?(不是我小气,我已经没分了!)