_CommandPtr

_CommandPtr_CommandPtr是一种函式,功能是提交的sql查询字元串指针 。
基本介绍中文名:CommandPtr
简介:提交的sql查询字元串指针
简介提交的sql查询字元串指针套用实例【_CommandPtr】_ConnectionPtr连结集连结即打开资料库m_SqlConnection.CreateInstance("ADODB.Connection");//strWay="driver={SQLServer};Server="+sqlname+";DATABASE=MyDataBase;UID="+sqluser+";PWD="+sqlpass;strWay="driver={SQLServer};Server="+sqlname+";DATABASE=调度信息库";m_SqlConnection->ConnectionTimeout=10;//设定逾时时间为10秒m_SqlConnection->CursorLocation=adUseClient;m_SqlConnection->Open((_bstr_t)strWay,(_bstr_t)sqluser,(_bstr_t)sqlpass,adModeUnknown);_RecordsetPtr记录集打开数据表(中的记录)m_SqlRecordset.CreateInstance("ADODB.Recordset");m_SqlRecordset->Open((_variant_t)("SELECT*FROM城市表WHERE省份='"+str+"'AND城市ISNOTNULL"),(IDispatch*)m_SqlConnection,adOpenStatic,adLockOptimistic,adCmdText);_CommandPtr命令集打开数据表即执行命令m_pCommand.CreateInstance("ADODB.Command");m_pCommand->ActiveConnection=m_SqlConnection;m_pCommand->CommandType=adCmdText;vNULL.vt=VT_ERROR;vNULL.scode=DISP_E_PARAMNOTFOUND;sprintf(buf,"DELETEFROM接收简讯WHEREID=%d",index);m_pCommand->CommandText=buf;//命令字串 。m_pCommand->Execute(&vNULL,&vNULL,adCmdText);///执行命令 。_ParameterPtr参数集主要用于存储过程_ParameterPtrparam;param=m_pCommand->CreateParameter(_bstr_t("@user"),adVarChar,adParamInput,20);param->Value=http://www.mancos-co.com/_variant_t(logname);.m_pCommand->Parameters->Append(param);_variant_tvNULL;vNULL.vt=VT_ERROR;vNULL.scode=DISP_E_PARAMNOTFOUND;m_pCommand->Execute(&vNULL,&vNULL,adCmdStoredProc);建议用属性更简单m_pCommand->Parameters->Refresh();m_pCommand->Parameters->Item["@user"]->Value=_variant_t(logname);m_pCommand->Parameters->Item["@operation"]->Value=_variant_t(operation);m_pCommand->Parameters->Item["@oper_type"]->Value=_variant_t(oper_type);再如://四种操作栏位的写入方法m_pRecordset->Collect["名称"]=_variant_t(m_strName);//m_pRecordset->Fields->Item["名称"]->Value=_variant_t(m_strName);//m_pRecordset->PutCollect("名称",_variant_t(m_strName));//m_pRecordset->GetFields()->GetItem("名称")->PutValue(_variant_t(m_strName));//四种操作栏位的读取方法m_cmbCity.AddString((_bstr_t)m_SqlRecordset->Collect["城市"]);//m_cmbCity.AddString((_bstr_t)m_SqlRecordset->Fields->Item["城市"]->Value);//m_cmbCity.AddString((_bstr_t)m_SqlRecordset->GetCollect("城市"));//m_cmbCity.AddString((_bstr_t)m_SqlRecordset->GetFields()->GetItem("城市")->GetValue());m_SqlRecordset.CreateInstance("ADODB.Recordset");m_SqlRecordset->CursorLocation=adUseClient;m_SqlRecordset->Open(_variant_t(str),_variant_t((IDispatch*)m_SqlConnection),adOpenStatic,adLockOptimistic,adCmdText);CStringstrFind;strFind.Format("主叫号码=%s",m_strCheck);strFind.Format("主叫号码LIKE/'%%%s%%/'",m_strCheck);m_SqlRecordset->Fields->Item["主叫号码"]->Properties->Item["Optimize"]->Value="True";m_SqlRecordset->Find((_bstr_t)strFind,1,adSearchForward);