ADO指针 _commandPtr 的用法

在VC++中使用_commandPtr 指针 一个小例子中,用于备忘: CString strSQL; strSQL = "select * from tb_hostlist"; _CommandPtr pCommamd; _RecordsetPtr pRecord; pCommamd.CreateInstance("ADODB.Command"); pRecord.CreateInstance("ADODB.Recordset"); try { pCommamd->CommandText = _bstr_t(strSQL); pCommamd->CommandType = adCmdText; pCommamd->ActiveConnection = pConnection; pRecord = pCommamd->Execute(NULL,NULL,adCmdText); int icount; icount = pRecord->RecordCount; VARIANT vtValue; while(!pRecord->AdoEOF) { vtValue = pRecord->GetCollect("mac") ; m_list.AddString((vtValue.vt == VT_NULL) ?"null":(CHAR*)_bstr_t(vtValue)); pRecord->MoveNext(); } } catch(_com_error &e) { m_list.AddString(e.ErrorMessage()); }

你可能感兴趣的:(command)