_bstr_t strConnect = "Provider=SQLOLEDB;Data Source=.;Initial Catalog=longkong;User ID=sa;Password=sa123456"; //打开数据库 p_connection1->Open(strConnect,"","",adModeUnknown);
CString sqlstr=""; sqlstr = "select OrderNo,Value from devvou "; //执行数据库语句 m_pRecordset = p_connection1->Execute((_bstr_t)sqlstr,NULL,adCmdText); //提取查询得到的参数
_variant_t showname = m_pRecordset->GetCollect ("OrderNo");
_variant_t detail = m_pRecordset->GetCollect ("Value");
CString stritemname =(char *)_bstr_t(showname);
stritemname.TrimRight();
CString strmeavalue =(char *)_bstr_t(detail); strmeavalue.TrimRight();
m_pRecordset-> MoveNext(); //关闭数据库连接
p_connection1->Close(); //新建一个新连接到自己的数据库
_bstr_t strConnectown = "Provider=SQLOLEDB;Data Source=.;Initial Catalog=ibms1;User ID=sa;Password=sa123456";
p_connection2->Open(strConnectown,"","",adModeUnknown);
CString sqlstr2="";
sqlstr2="update ibms_point_info set MeaValue='"+strmeavalue+"' where CPOINTID='"+stritemname+"'"; //更新自己的数据库
m_pRecordset = p_connection2->Execute((_bstr_t)sqlstr2,NULL,adCmdText); //关闭
p_connection2->Close(); }
catch(_com_error &e) { }
这样看起来有点乱。
乱码,谁有心情看