???????????ADO????????????????COM??????????(CoInitialize).????????????????????????????£?
#import "C:Program Files/Common Files/System/ado/msado15.dll" rename("EOF"?? "adoEOF")    //????C++?????EOF??????????
using namespace ADODB;
BOOL ADOConnect(CString strDBFile)
{
_ConnectionPtr pConnection;
if(pConnection.CreateInstance(__uuidof(Connection)) != S_OK)
{
return FALSE;
}
CString strConnect;
strConnect.Format(_T("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%s")?? strDBFile);
if(pConnection->Open(_bstr_t(strConnect)?? ""?? ""?? adModeUnknown) == S_OK)
{
//???????????
_RecordsetPtr pRecordset;
if(pRecordset.CreateInstance(__uuidof(Recordset)) != S_OK)
{
pConnection->Close();
return FALSE;
}
CString strSql;
strSql = _T("select * from info");
HRESULT hr = pRecordset->Open(_bstr_t(strSql)?? _variant_t((IDispatch*)pConnection?? TRUE)?? adOpenUnspecified?? adLockUnspecified?? adCmdUnknown);
if(hr != S_OK)
{
pConnection->Close();
return FALSE;
}
_variant_t vt;
pRecordset->MoveFirst();
while(!pRecordset->adoEOF)
{
vt = pRecordset->Fields->GetItem("????")->Value;
pRecordset->MoveNext();
}
pConnection->Close();
return TRUE;
}
return FALSE;
}