vc access数据库 怎么在 查询where 添加变量 where id=a 这个错误的 下面的代码怎么改
#import "c:\program files\common files\system\ado\msado15.dll" \
no_namespace rename ("EOF", "adoEOF")
void ak(HWND hwnd)
{
_ConnectionPtr m_pConnection;
CoInitialize(NULL);
m_pConnection.CreateInstance(__uuidof(Connection));
try
{
m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\测试C\\hhh\\1.mdb","","",adModeUnknown);
}
catch(_com_error e){
} _RecordsetPtr m_pRecordset;
m_pRecordset.CreateInstance(__uuidof(Recordset));
try
{
int a=1; //定义变量
m_pRecordset->Open("SELECT * FROM bi where id=变量 order by id asc", //怎么添加变量
m_pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
_variant_t var; var=m_pRecordset->GetCollect("a1");
char *strID= _com_util::ConvertBSTRToString((_bstr_t)var);//转换为字符串
SetDlgItemText(hwnd,IDC_EDIT1,strID); //文本框
}
catch(_com_error *e){}
m_pRecordset->Close();
m_pRecordset = NULL;
if(m_pConnection->State)
{
m_pConnection->Close();
m_pConnection= NULL;
}
}
|