voidCAOD1Dlg::OnButton1()
{
//TODO:Addyourcontrolnotificationhandlercodehere
USES_CONVERSION;
::CoInitialize(NULL);
_ConnectionPtrcon(__uuidof(Connection));
_RecordsetPtrrst(__uuidof(Recordset));
_CommandPtrcmd(__uuidof(Command));
try{
con-Open((\"Provider=Microsoft.ACE.OLEDB.12.0;DataSource=C://Example.accdb\"),\"\",\"\",adModeUnknown);
}
catch(_com_errore)
{
AfxMessageBox(\"Sorry\"e.Description());
}
rst-Open(_variant_t(\"select*frominfo_reader\"),
_variant_t((IDispatch*)con),adOpenDynamic,
adLockOptimistic,-1);
while(!rst-adoEOF)
{
m_list.AddString(W2A(rst-GetCollect(_variant_t(\"name\")).bstrVal));
rst-MoveNext();
}
//rst-Close();
//con-Close();
}
|