ADO _RecordsetPtr: how to PutCollect() a NULL value?
-
These code put a string into name which is a column in database table
_RecordsetPtr rec; rec.CreateInstance(_uuidof(Recordset)); CString cstrSQL; cstrSQL.Format("SELECT * FROM ... where ..."); rec->Open(_bstr_t(cstrSQL), (IDispatch*)g_pConnections, adOpenDynamic, adLockOptimistic, adCmdText); rec->PutCollect("name",_variant_t("my name")); rec->Update();
But,how to PutCollect a NULL value into this column? -
These code put a string into name which is a column in database table
_RecordsetPtr rec; rec.CreateInstance(_uuidof(Recordset)); CString cstrSQL; cstrSQL.Format("SELECT * FROM ... where ..."); rec->Open(_bstr_t(cstrSQL), (IDispatch*)g_pConnections, adOpenDynamic, adLockOptimistic, adCmdText); rec->PutCollect("name",_variant_t("my name")); rec->Update();
But,how to PutCollect a NULL value into this column?_RecordsetPtr rec; rec.CreateInstance(_uuidof(Recordset)); CString cstrSQL; cstrSQL.Format("SELECT * FROM ... where ..."); rec->Open(_bstr_t(cstrSQL), (IDispatch*)g_pConnections, adOpenDynamic, adLockOptimistic, adCmdText); if(sName =="") //NULL { rec->PutCollect("name", VT_NULL); } else { rec->PutCollect("name",_variant_t("my name")); } rec->Update();