Solutions to access database self-starting difficulties

Source: Internet
Author: User
After the tests over the past few days, I had nothing to worry about. I found that the access database connection error was self-initiated by the program. After the program was started, I re-opened the file to connect to the database normally.

After the tests over the past few days, I had nothing to worry about. I found that the access database connection error was self-initiated by the program. After the program was started, I re-opened the file to connect to the database normally.

Problem Analysis for a long time,
After troubleshooting, the problem lies in the database startup path, which can be written when you connect to the database.
GetModuleFileName (NULL, path, 255); // obtain the complete path of the self-starting program;
CString str;
Str. Format ("% s", path );
Int place;
Place = str. ReverseFind ('\'); // obtain the position of the last;
CString db_name;
Db_name = str. Left (place + 1) + "qijian. mdb"; // integrate the full path of the access Database
CString connect; // The first connection parameter.
Connect = "Provider = Microsoft. Jet. OLEDB.4.0; Data Source =" + db_name + ";";
Hr = theApp. m_pConnection-> Openconnect. GetBuffer (connect. GetLength (), "", "", adModeUnknown); // input and connect Parameters
You do not need to modify other codes.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.