_ RecordsetPtr m _ pSet
SQL =“Select * from a where name like“% b %““
theapp . ado-& gt;execute command(sqlstr,m _ pSet);
//後跟您的代碼。
//ExecuteCommand的代碼
int CMyAdo::execute command(CString SQL,_ RecordsetPtr & amprst)
{
嘗試
{
_ variant _ t vNULL
vNULL.vt = VT _ ERROR
v null . scode = DISP _ E _ param not found;
命令-& gt;ActiveConnection = conn
命令-& gt;CommandText =(_ bstr _ t)SQL;
rst = command-& gt;執行(& ampv null & amp;vNULL,ADC mdtext);
返回0;
}
catch(_ com _ error Err)
{
AfxMessageBox(錯誤description());
返回-1;
}
}