Home > Software engineering >  MFC connection access, the debug ok, running exe cannot connect to the database
MFC connection access, the debug ok, running exe cannot connect to the database

Time:11-15

_ConnectionPtr m_pConnection;//ConnectionPtr pointer is used to open and close a repository connection or use it to the Execute method to Execute a command does not return results statement
_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 same

CodePudding 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
  • Related