词条 | _CommandPtr |
释义 | 简介提交的sql查询字符串指针 应用实例_ConnectionPtr链接集链接即打开数据库 m_SqlConnection.CreateInstance("ADODB.Connection"); // strWay="driver={SQL Server};Server=" + sqlname + ";DATABASE=MyDataBase;UID=" + sqluser + ";PWD=" + sqlpass; strWay="driver={SQL Server};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 城市 IS NOT NULL"), (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,"DELETE FROM 接收短信 WHERE ID=%d",index); m_pCommand->CommandText=buf; //命令字串。 m_pCommand->Execute(&vNULL,&vNULL,adCmdText);///执行命令。 _ParameterPtr 参数集主要用于存储过程 _ParameterPtr param; param=m_pCommand->CreateParameter(_bstr_t("@user"),adVarChar,adParamInput,20); param->Value=_variant_t(logname);. m_pCommand->Parameters->Append(param); _variant_t vNULL; 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); CString strFind; 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); |
随便看 |
百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。