This article is organized by Code Assistant software to publish content unrelated to the software
more enjoyable reading, more enjoyable writing, easier publishing
0 connecting the database
#import "C:\Program Files\Common Files\system\ado\msado15.dll" no_namespace rename ("EOF", "adoeof") Rename ("BOF", "Adobof")_connectionptr m_pconnection; Database connection _connectionptr m_pconnectionstu;//Student Information database bool Connectdatabase(); Connecting Database BOOL Cketangapp::connectdatabase(){:: CoInitialize(NULL);Try{Test database Connection HRESULTHR=M_pconnection.createinstance(__uuidof(Connection));if(FAILED(HR)){AfxMessageBox(_t("Create connection instance failed-question"));returnFALSE;}HR=M_pconnection->open(_t("Provider=Microsoft.ACE.OLEDB. A.0;D ATA Source=Shiti.accdb "), _t(""), _t(""), adModeUnknown);if(FAILED(HR)){AfxMessageBox(_t("The SHITI.ACCDB database does not exist or the path is incorrect");}Student Database ConnectionHR=M_pconnectionstu.createinstance(__uuidof(Connection));if(FAILED(HR)){AfxMessageBox(_t("Create connection instance failed-student");returnFALSE;}HR=M_pconnectionstu->open(_t("Provider=Microsoft.ACE.OLEDB. A.0;D ATA Source=Student.accdb "), _t(""), _t(""), adModeUnknown
)
if(FAILED(HR)){AfxMessageBox(_t("The STUDENT.ACCDB database does not exist or the path is incorrect");}}Catch(_com_error&e){AfxMessageBox(_t("The database has been opened or not present or the path is incorrect");;returnFALSE;}}intCketangapp::ExitInstance() {Todo:addyourSpecializedCode Hereand/orPager theBaseclassif(M_pconnection)if(M_pconnection->state)James M_pconnection->Close();if(M_pconnectionstu)if(M_pconnectionstu->state)James M_pconnectionstu->Close(); Gdiplusshutdown(Gdiplustoken);returnCWINAPP::ExitInstance();}
Connecting to a database