??????????????????????????????????????????????????????mysql??????????ù???????????access??sql server?????????????Щ?????????????????????????C++????mysql??????????????2?????????
??????????????????ADO?????
??????????????????mysql?????api?????????????
??????????????????????????????????????????????????????????????????????mysql??sqlserver??oracle??access??????access??????????????SQL??????????SQL?????????Щ?????????????????????????????????mysql???????????????????????????e??MyODBC??????????
?????????????????????????????Mysql??????????????“mysql??????Щ????”???e?????Navicat for mysql?????????mysql?????????????????????????
????????????ADO????MySql?????
????1?????ADO????MySql?????????e??MyODBC??????????
????MyODBC?汾???MySql??汾????????????????????????????汾?????mysql-5.1.48-win32.msi??mysql-connector-odbc-5.1.5-win32.msi??
????????ú????????????>?????>??????壭>????????>?????(ODBC)??>???DSN??>????>???MySQL ODBC 5.1 Driver?????????

??????????MySQL ODBC 5.1 Driver???????á????ú?????Test?????2?????????????????????????connection successful?????

????????е?Data Source Name:?е????????????DSN??????????
???????磺"DSN=MySqlODBC;server=localhost;database=test"??
????2?????úú??????????????
??????1?????????ADO?????#import "c:program filescommon filessystemadomsado15.dll" no_namespace rename("EOF"??"adoEOF")???????????msado15.dll?????????????£??????????????????msado15.dll?????????????????????£????#import "msado15.dll" no_namespace ename ("EOF"?? "adoEOF")??????????
??????2 ??????Connection?????????????
{
CoInitialize(NULL);
m_pConnection.CreateInstance(__uuidof(Connection));
try
{
//???????????
m_pConnection->ConnectionTimeout = 5;
//???????????
HRESULT hr = m_pConnection->Open("DSN=MySqlODBC;server=localhost;database=test"??"root"??"root"??adModeUnknown);
}
catch(_com_error &e)
{
MessageBox(NULL?? e.Description()?? _T("")?? MB_OK);
return FALSE;
}
return TRUE;
}
(3)???SQL???
BOOL CDBManagerSub::ExecuteSQL( _bstr_t bstrSQL )
{
// _variant_t RecordsAffected;
try
{
// ???????????????
if(m_pConnection == NULL)
{
//?????????????
Open(m_dbType?? m_strServer?? m_strUserName?? m_strPasswor?? m_strDBName);
}
// Connection?????Execute????:(_bstr_t CommandText??
// VARIANT * RecordsAffected?? long Options )
// ????CommandText????????????????SQL???
// ????RecordsAffected?????????????????????
// ????Options???CommandText???????adCmdText-???????adCmdTable-????
// adCmdProc-?洢?????adCmdUnknown-δ?
_RecordsetPtr hr = m_pConnection->Execute(bstrSQL??NULL??adCmdText);
return true;
}
catch(_com_error e)
{
MessageBox(NULL?? e.Description()?? _T("")?? MB_OK);
return false;
}
}
????_bstr_t bstrSQL??????SQL??????????TRUE??????г????????FLASH????????????????