我正在使用ADO与C ++,我有关于在Recordset中查找特定记录的问题。我写了连接到数据库,Recordset.Open等...所以一切顺利。我想要找到哪条记录已存在于数据库中,但Recordset-> Find方法无法在Recordset中找到该特定数据。你能看看我的代码并告诉我哪里出错了吗?或者这是写Recordset-> Find()方法P的正确语法。我是ADO中的新手,所以我不知道这是否是正确的语法。先感谢您。
我已经尝试通过Fields-> GetItem返回记录并且它有效。它返回“nikala”。(如果它确实很重要。)这意味着Recordset打开得很好。 _bstr_t AccReturn = pRecst->Fields->GetItem("Account")->Value;
我的代码:
pRecst->MoveFirst();
bool found = pRecst->Find("[Account] = 'nikala'", 0, adSearchForward);
if(found == true)
{
//update code
}
else
{
//insert into DB
}
这是样本: