_RecordsetPtr m_pRecordset;//_RecordsetPtr smart Pointers can be used to open the data table, and on the records in a table, fields, and so on for various operation
Cstrings csSQLstr;
Cstrings SN_code;
CsSQLstr="SELECT * FROM SN_CHECK";//test for steps and build a database table name,
M_pConnection. CreateInstance (__uuidof (Connection));
Try
{
//create the ADO connection
M_pConnection - & gt; Open (" Provider=Microsoft. ACE. The OLEDB. 12.0; Data Source=SN_Code. Accdb ", ""," ", adModeUnknown);
//the database files in the same as the code file directory, data source form of assignment of the statements can be written as
}
Catch _com_error (e)
{
AfxMessageBox (_T (" database connection fails, confirm whether the database in the current path!" ));
return;
}
Database has been even when running exe, "database connection fails, confirm whether the database in the current path!"
Request bosses to solve!
CodePudding user response:
View the data source and you write the sameCodePudding user response:
Address code ~ no problem, my company will give the database file encryption, exe cannot link, plagued me for two days, forgot all about it