VC++数据库更新
try
{strSQL.Format("select count(*) as name from datatable where pusername=%s and starTime=%s ",dusername,startime);
_variant_t m_pRecordset2,var;
m_pConnection->CursorLocation = adUseClient;
m_pRecordset=m_pConnection->Execute(_bstr_t(strSQL), &m_pRecordset2, adCmdText);
var=m_pRecordset->GetCollect((_variant_t)((long)0));
if(var.lVal!=0)
{
_variant_t var2;
strSQL1.Format("update datatable set stopTime='%s',sendByet='%s' where pusername=%S and starTime=%s",endtime,sendb,dusername,startime);
m_pConnection->CursorLocation = adUseClient;
m_pConnection->Execute(_bstr_t(strSQL1), &var2, adCmdText);
m_pRecordset->Update();
m_pRecordset->Close();
}
else
{
}
我很菜的啊。我想更具数据库里的内容进行更新,如果有记录就更新。请大侠帮忙看看啊!