MFC对话框如何连接Access数据库的数据?


解决方案:

try
{
hr = m_pConnection.CreateInstance("ADODB.Connection");///
if( TRUE == SUCCEEDED(hr))
{
strDBFile = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strDBFile;
hr = m_pConnection->Open((_bstr_t)strDBFile ,_bstr_t(strUser),_bstr_t(strUser),adModeUnknown);
}
}
catch(_com_error e)
{
CString errormessage;
errormessage.Format("%s",e.ErrorMessage());
AfxMessageBox(errormessage);
return FALSE;
}


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3